added some more rigorous checking of session connected-ness and some logging
authorerickson <erickson@9efc2488-bf62-4759-914b-345cdb29e865>
Wed, 26 Sep 2007 15:17:36 +0000 (15:17 +0000)
committererickson <erickson@9efc2488-bf62-4759-914b-345cdb29e865>
Wed, 26 Sep 2007 15:17:36 +0000 (15:17 +0000)
git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1092 9efc2488-bf62-4759-914b-345cdb29e865

src/java/org/opensrf/Sys.java
src/java/org/opensrf/net/xmpp/XMPPSession.java

index 85fb118..1e52bb3 100644 (file)
@@ -20,7 +20,8 @@ public class Sys {
             throws ConfigException, SessionException  {
 
         /** see if the current thread already has a connection */
-        if(XMPPSession.getThreadSession() != null)
+        XMPPSession existing = XMPPSession.getThreadSession();
+        if(existing != null && existing.connected())
             return;
 
         /** create the config parser */
@@ -47,8 +48,8 @@ public class Sys {
         try {
 
             /** Connect to the Jabber network */
+            Logger.info("attempting to create XMPP session "+username+"@"+host+"/"+res);
             XMPPSession xses = new XMPPSession(host, port);
-            System.out.println("resource = " + res);
             xses.connect(username, passwd, res);
             XMPPSession.setThreadSession(xses);
 
index cc2a9f6..df9a84f 100644 (file)
@@ -119,9 +119,10 @@ public class XMPPSession {
     /** true if this session is connected to the server */
     public boolean connected() {
         return (
-            reader != null && 
-            reader.getXMPPStreamState() == 
-                XMPPReader.XMPPStreamState.CONNECTED);
+                reader != null && 
+                reader.getXMPPStreamState() == XMPPReader.XMPPStreamState.CONNECTED &&
+                !socket.isClosed()
+            );
     }