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 */
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);
/** 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()
+ );
}