aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/xmpp/s2s/Connection.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/juick/xmpp/s2s/Connection.java')
-rw-r--r--src/main/java/com/juick/xmpp/s2s/Connection.java35
1 files changed, 15 insertions, 20 deletions
diff --git a/src/main/java/com/juick/xmpp/s2s/Connection.java b/src/main/java/com/juick/xmpp/s2s/Connection.java
index 699e52bf..1a14b2cc 100644
--- a/src/main/java/com/juick/xmpp/s2s/Connection.java
+++ b/src/main/java/com/juick/xmpp/s2s/Connection.java
@@ -1,14 +1,16 @@
package com.juick.xmpp.s2s;
+import org.xmlpull.mxp1.MXParser;
+import org.xmlpull.v1.XmlPullParser;
+
+import javax.crypto.Mac;
+import javax.crypto.spec.SecretKeySpec;
import java.io.FileWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
-import java.net.Socket;
+import java.nio.channels.AsynchronousSocketChannel;
import java.util.Date;
-import javax.crypto.Mac;
-import javax.crypto.spec.SecretKeySpec;
-import org.xmlpull.mxp1.MXParser;
-import org.xmlpull.v1.XmlPullParser;
+import java.util.logging.Logger;
/**
*
@@ -16,12 +18,14 @@ import org.xmlpull.v1.XmlPullParser;
*/
public class Connection {
+ protected static final Logger LOGGER = Logger.getLogger(Connection.class.getName());
+
public String streamID;
public long tsCreated = 0;
public long tsLocalData = 0;
public long bytesLocal = 0;
public long packetsLocal = 0;
- Socket socket;
+ AsynchronousSocketChannel socket;
final XmlPullParser parser = new MXParser();
OutputStreamWriter writer;
@@ -29,15 +33,6 @@ public class Connection {
tsCreated = System.currentTimeMillis();
}
- public void logXml(String xml) {
- try {
- FileWriter logFile = new FileWriter(XMPPComponent.LOGFILE, true);
- logFile.write(new Date().toString() + "\t" + streamID + "\t" + xml);
- logFile.close();
- } catch (IOException e) {
- }
- }
-
public void logParser() {
if (streamID == null) {
return;
@@ -47,12 +42,12 @@ public class Connection {
tag += " " + parser.getAttributeName(i) + "=\"" + parser.getAttributeValue(i) + "\"";
}
tag += ">...</" + parser.getName() + ">\n";
- logXml(tag);
+ LOGGER.fine(tag);
}
public void sendStanza(String xml) throws IOException {
- if (XMPPComponent.LOGFILE != null && streamID != null) {
- logXml("OUT: " + xml + "\n");
+ if (streamID != null) {
+ LOGGER.fine("OUT: " + xml + "\n");
}
writer.write(xml);
writer.flush();
@@ -62,8 +57,8 @@ public class Connection {
}
void closeConnection() {
- if (XMPPComponent.LOGFILE != null && streamID != null) {
- logXml("CLOSING STREAM\n");
+ if (streamID != null) {
+ LOGGER.info(String.format("CLOSING STREAM %s", streamID));
}
try {