Commit 732be5f4 authored by Daniel Henninger's avatar Daniel Henninger Committed by dhenninger

[GATE-81] Detecting network disconnects now.

Lots of debugging.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk/src/plugins/gateway@5763 b35dd754-fafc-0310-a699-88a17e54d16e
parent 45242d56
...@@ -49,13 +49,19 @@ public class BOSConnection extends BasicFlapConnection { ...@@ -49,13 +49,19 @@ public class BOSConnection extends BasicFlapConnection {
} }
protected void handleStateChange(ClientConnEvent e) { protected void handleStateChange(ClientConnEvent e) {
Log.debug("OSCAR bos service state change from "+e.getOldState()+" to "+e.getNewState());
if (e.getNewState() == ClientFlapConn.STATE_NOT_CONNECTED && e.getOldState() == ClientFlapConn.STATE_CONNECTED && getMainSession().isLoggedIn()) {
getMainSession().bosDisconnected();
}
} }
protected void handleFlapPacket(FlapPacketEvent e) { protected void handleFlapPacket(FlapPacketEvent e) {
Log.debug("OSCAR bps flap packet received: "+e);
super.handleFlapPacket(e); super.handleFlapPacket(e);
} }
protected void handleSnacPacket(SnacPacketEvent e) { protected void handleSnacPacket(SnacPacketEvent e) {
Log.debug("OSCAR bos snac packet received: "+e);
super.handleSnacPacket(e); super.handleSnacPacket(e);
SnacCommand cmd = e.getSnacCommand(); SnacCommand cmd = e.getSnacCommand();
...@@ -71,6 +77,8 @@ public class BOSConnection extends BasicFlapConnection { ...@@ -71,6 +77,8 @@ public class BOSConnection extends BasicFlapConnection {
protected void handleSnacResponse(SnacResponseEvent e) { protected void handleSnacResponse(SnacResponseEvent e) {
super.handleSnacResponse(e); super.handleSnacResponse(e);
Log.debug("OSCAR bos snac response received: "+e);
SnacCommand cmd = e.getSnacCommand(); SnacCommand cmd = e.getSnacCommand();
if (cmd instanceof LocRightsCmd) { if (cmd instanceof LocRightsCmd) {
......
...@@ -73,6 +73,7 @@ public abstract class BasicFlapConnection extends BaseFlapConnection { ...@@ -73,6 +73,7 @@ public abstract class BasicFlapConnection extends BaseFlapConnection {
DateFormat.SHORT); DateFormat.SHORT);
protected void handleFlapPacket(FlapPacketEvent e) { protected void handleFlapPacket(FlapPacketEvent e) {
Log.debug("OSCAR flap packet received: "+e);
FlapCommand cmd = e.getFlapCommand(); FlapCommand cmd = e.getFlapCommand();
if (cmd instanceof LoginFlapCmd) { if (cmd instanceof LoginFlapCmd) {
...@@ -81,6 +82,7 @@ public abstract class BasicFlapConnection extends BaseFlapConnection { ...@@ -81,6 +82,7 @@ public abstract class BasicFlapConnection extends BaseFlapConnection {
} }
protected void handleSnacPacket(SnacPacketEvent e) { protected void handleSnacPacket(SnacPacketEvent e) {
Log.debug("OSCAR snac packet received: "+e);
SnacCommand cmd = e.getSnacCommand(); SnacCommand cmd = e.getSnacCommand();
if (cmd instanceof ServerReadyCmd) { if (cmd instanceof ServerReadyCmd) {
ServerReadyCmd src = (ServerReadyCmd) cmd; ServerReadyCmd src = (ServerReadyCmd) cmd;
......
...@@ -36,6 +36,7 @@ public class LoginConnection extends BaseFlapConnection { ...@@ -36,6 +36,7 @@ public class LoginConnection extends BaseFlapConnection {
} }
protected void handleStateChange(ClientConnEvent e) { protected void handleStateChange(ClientConnEvent e) {
Log.debug("OSCAR login service state change from "+e.getOldState()+" to "+e.getNewState());
if (e.getNewState() == ClientFlapConn.STATE_CONNECTED) { if (e.getNewState() == ClientFlapConn.STATE_CONNECTED) {
getFlapProcessor().sendFlap(new LoginFlapCmd()); getFlapProcessor().sendFlap(new LoginFlapCmd());
request(new KeyRequest(oscarSession.getRegistration().getUsername())); request(new KeyRequest(oscarSession.getRegistration().getUsername()));
......
...@@ -34,6 +34,8 @@ import org.jivesoftware.wildfire.user.UserNotFoundException; ...@@ -34,6 +34,8 @@ import org.jivesoftware.wildfire.user.UserNotFoundException;
import org.jivesoftware.wildfire.roster.RosterItem; import org.jivesoftware.wildfire.roster.RosterItem;
import org.xmpp.packet.JID; import org.xmpp.packet.JID;
import org.xmpp.packet.Presence; import org.xmpp.packet.Presence;
import org.xmpp.packet.Message;
import org.xmpp.packet.PacketError;
/** /**
* Represents an OSCAR session. * Represents an OSCAR session.
...@@ -333,9 +335,11 @@ public class OSCARSession extends TransportSession { ...@@ -333,9 +335,11 @@ public class OSCARSession extends TransportSession {
} }
void serviceFailed(ServiceConnection conn) { void serviceFailed(ServiceConnection conn) {
Log.debug("OSCAR service failed: "+conn.toString());
} }
void serviceConnected(ServiceConnection conn) { void serviceConnected(ServiceConnection conn) {
Log.debug("OSCAR service connected: "+conn.toString());
services.add(conn); services.add(conn);
} }
...@@ -348,14 +352,27 @@ public class OSCARSession extends TransportSession { ...@@ -348,14 +352,27 @@ public class OSCARSession extends TransportSession {
} }
void serviceReady(ServiceConnection conn) { void serviceReady(ServiceConnection conn) {
Log.debug("OSCAR service ready: "+conn.toString());
snacMgr.dequeueSnacs(conn); snacMgr.dequeueSnacs(conn);
} }
void serviceDied(ServiceConnection conn) { void serviceDied(ServiceConnection conn) {
Log.debug("OSCAR service died: "+conn.toString());
services.remove(conn); services.remove(conn);
snacMgr.unregister(conn); snacMgr.unregister(conn);
} }
void bosDisconnected() {
Message m = new Message();
m.setType(Message.Type.error);
m.setError(PacketError.Condition.internal_server_error);
m.setTo(getJID());
m.setFrom(getTransport().getJID());
m.setBody("You have been disconnected automatically by the server.");
getTransport().sendPacket(m);
logOut();
}
/** /**
* We've been told about a buddy that exists on the buddy list. * We've been told about a buddy that exists on the buddy list.
* *
......
...@@ -22,6 +22,7 @@ import net.kano.joscar.snac.SnacPacketEvent; ...@@ -22,6 +22,7 @@ import net.kano.joscar.snac.SnacPacketEvent;
import net.kano.joscar.snac.SnacResponseEvent; import net.kano.joscar.snac.SnacResponseEvent;
import net.kano.joscar.net.ClientConnEvent; import net.kano.joscar.net.ClientConnEvent;
import net.kano.joscar.net.ConnDescriptor; import net.kano.joscar.net.ConnDescriptor;
import org.jivesoftware.util.Log;
/** /**
* Represents a connection to a particular OSCAR service. * Represents a connection to a particular OSCAR service.
...@@ -44,6 +45,7 @@ public class ServiceConnection extends BasicFlapConnection { ...@@ -44,6 +45,7 @@ public class ServiceConnection extends BasicFlapConnection {
} }
protected void handleStateChange(ClientConnEvent e) { protected void handleStateChange(ClientConnEvent e) {
Log.debug("OSCAR service state change from "+e.getOldState()+" to "+e.getNewState());
if (e.getNewState() == ClientFlapConn.STATE_FAILED) { if (e.getNewState() == ClientFlapConn.STATE_FAILED) {
oscarSession.serviceFailed(this); oscarSession.serviceFailed(this);
} else if (e.getNewState() == ClientFlapConn.STATE_CONNECTED) { } else if (e.getNewState() == ClientFlapConn.STATE_CONNECTED) {
......
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