Commit 007bdef9 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gaston

Added tracking of sending operations. JM-297


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/branches@1405 b35dd754-fafc-0310-a699-88a17e54d16e
parent 242f5307
......@@ -88,6 +88,8 @@ public class SocketConnection implements Connection {
}
try {
synchronized (writer) {
// Register that we started sending data on the connection
SocketSendingTracker.getInstance().socketStartedSending(socket);
writer.write(" ");
writer.flush();
}
......@@ -96,6 +98,10 @@ public class SocketConnection implements Connection {
Log.warn("Closing no longer valid connection" + "\n" + this.toString(), e);
close();
}
finally {
// Register that we finished sending data on the connection
SocketSendingTracker.getInstance().socketFinishedSending(socket);
}
return !isClosed();
}
......@@ -197,6 +203,8 @@ public class SocketConnection implements Connection {
}
synchronized (writer) {
try {
// Register that we started sending data on the connection
SocketSendingTracker.getInstance().socketStartedSending(socket);
writer.write("</stream:stream>");
if (flashClient) {
writer.write('\0');
......@@ -204,6 +212,10 @@ public class SocketConnection implements Connection {
xmlSerializer.flush();
}
catch (IOException e) {}
finally {
// Register that we finished sending data on the connection
SocketSendingTracker.getInstance().socketFinishedSending(socket);
}
}
}
catch (Exception e) {
......@@ -236,6 +248,8 @@ public class SocketConnection implements Connection {
boolean errorDelivering = false;
synchronized (writer) {
try {
// Register that we started sending data on the connection
SocketSendingTracker.getInstance().socketStartedSending(socket);
xmlSerializer.write(packet.getElement());
if (flashClient) {
writer.write('\0');
......@@ -246,6 +260,10 @@ public class SocketConnection implements Connection {
Log.debug("Error delivering packet" + "\n" + this.toString(), e);
errorDelivering = true;
}
finally {
// Register that we finished sending data on the connection
SocketSendingTracker.getInstance().socketFinishedSending(socket);
}
}
if (errorDelivering) {
close();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment