Commit c415082e authored by Matt Tucker's avatar Matt Tucker Committed by matt

Attempt at better closed socket detection.


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@879 b35dd754-fafc-0310-a699-88a17e54d16e
parent df44b6df
...@@ -61,13 +61,9 @@ public class SocketConnection extends BasicConnection { ...@@ -61,13 +61,9 @@ public class SocketConnection extends BasicConnection {
* Audits packets * Audits packets
*/ */
private Auditor auditor; private Auditor auditor;
private Session session; private Session session;
private boolean secure; private boolean secure;
private XMLWriter xmlSerializer; private XMLWriter xmlSerializer;
private boolean flashClient = false; private boolean flashClient = false;
/** /**
...@@ -79,9 +75,9 @@ public class SocketConnection extends BasicConnection { ...@@ -79,9 +75,9 @@ public class SocketConnection extends BasicConnection {
* @param isSecure True if this is a secure connection * @param isSecure True if this is a secure connection
* @throws NullPointerException If the socket is null * @throws NullPointerException If the socket is null
*/ */
public SocketConnection(PacketDeliverer deliverer, Auditor auditor, public SocketConnection(PacketDeliverer deliverer, Auditor auditor, Socket socket,
Socket socket, boolean isSecure) throws IOException { boolean isSecure) throws IOException
{
if (socket == null) { if (socket == null) {
throw new NullPointerException("Socket channel must be non-null"); throw new NullPointerException("Socket channel must be non-null");
} }
...@@ -129,17 +125,11 @@ public class SocketConnection extends BasicConnection { ...@@ -129,17 +125,11 @@ public class SocketConnection extends BasicConnection {
/** /**
* Retrieve the closed state of the Session. * Retrieve the closed state of the Session.
* *
* @return True if the session is closed * @return true if the session is closed.
*/ */
public boolean isClosed() { public boolean isClosed() {
if (session == null) { if (session == null) {
try { return sock.isClosed();
sock.getInputStream();
}
catch (IOException e) {
return false;
}
return true;
} }
return session.getStatus() == Session.STATUS_CLOSED; return session.getStatus() == Session.STATUS_CLOSED;
} }
...@@ -171,8 +161,7 @@ public class SocketConnection extends BasicConnection { ...@@ -171,8 +161,7 @@ public class SocketConnection extends BasicConnection {
/** /**
* Delivers the packet to this XMPPAddress without checking the recipient. * Delivers the packet to this XMPPAddress without checking the recipient.
* The method essentially calls * The method essentially calls <tt>packet.send(serializer,version)</tt>.
* <code>packet.send(serializer,version)</code>
* *
* @param packet The packet to deliver. * @param packet The packet to deliver.
*/ */
...@@ -190,8 +179,8 @@ public class SocketConnection extends BasicConnection { ...@@ -190,8 +179,8 @@ public class SocketConnection extends BasicConnection {
xmlSerializer.flush(); xmlSerializer.flush();
} }
catch (IOException e) { catch (IOException e) {
Log.error("Problem sending the following packet: "+packet.toXML());
Log.error(e); Log.error(e);
close();
} }
} }
auditor.audit(packet, session); auditor.audit(packet, session);
...@@ -206,4 +195,4 @@ public class SocketConnection extends BasicConnection { ...@@ -206,4 +195,4 @@ public class SocketConnection extends BasicConnection {
public boolean isFlashClient() { public boolean isFlashClient() {
return flashClient; return flashClient;
} }
} }
\ No newline at end of file
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