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
......@@ -37,7 +37,7 @@ import org.xmpp.packet.Presence;
* @author Daniel Henninger
* Heavily inspired by joscardemo from the joscar project.
*/
public class BOSConnection extends BasicFlapConnection {
public class BOSConnection extends BasicFlapConnection {
protected SsiItemObjectFactory itemFactory = new DefaultSsiItemObjFactory();
private static final List<CapabilityBlock> MY_CAPS = Arrays.asList(
......@@ -49,13 +49,19 @@ public class BOSConnection extends BasicFlapConnection {
}
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) {
Log.debug("OSCAR bps flap packet received: "+e);
super.handleFlapPacket(e);
}
protected void handleSnacPacket(SnacPacketEvent e) {
Log.debug("OSCAR bos snac packet received: "+e);
super.handleSnacPacket(e);
SnacCommand cmd = e.getSnacCommand();
......@@ -71,6 +77,8 @@ public class BOSConnection extends BasicFlapConnection {
protected void handleSnacResponse(SnacResponseEvent e) {
super.handleSnacResponse(e);
Log.debug("OSCAR bos snac response received: "+e);
SnacCommand cmd = e.getSnacCommand();
if (cmd instanceof LocRightsCmd) {
......
......@@ -73,6 +73,7 @@ public abstract class BasicFlapConnection extends BaseFlapConnection {
DateFormat.SHORT);
protected void handleFlapPacket(FlapPacketEvent e) {
Log.debug("OSCAR flap packet received: "+e);
FlapCommand cmd = e.getFlapCommand();
if (cmd instanceof LoginFlapCmd) {
......@@ -81,6 +82,7 @@ public abstract class BasicFlapConnection extends BaseFlapConnection {
}
protected void handleSnacPacket(SnacPacketEvent e) {
Log.debug("OSCAR snac packet received: "+e);
SnacCommand cmd = e.getSnacCommand();
if (cmd instanceof ServerReadyCmd) {
ServerReadyCmd src = (ServerReadyCmd) cmd;
......
......@@ -36,6 +36,7 @@ public class LoginConnection extends BaseFlapConnection {
}
protected void handleStateChange(ClientConnEvent e) {
Log.debug("OSCAR login service state change from "+e.getOldState()+" to "+e.getNewState());
if (e.getNewState() == ClientFlapConn.STATE_CONNECTED) {
getFlapProcessor().sendFlap(new LoginFlapCmd());
request(new KeyRequest(oscarSession.getRegistration().getUsername()));
......
......@@ -34,6 +34,8 @@ import org.jivesoftware.wildfire.user.UserNotFoundException;
import org.jivesoftware.wildfire.roster.RosterItem;
import org.xmpp.packet.JID;
import org.xmpp.packet.Presence;
import org.xmpp.packet.Message;
import org.xmpp.packet.PacketError;
/**
* Represents an OSCAR session.
......@@ -333,9 +335,11 @@ public class OSCARSession extends TransportSession {
}
void serviceFailed(ServiceConnection conn) {
Log.debug("OSCAR service failed: "+conn.toString());
}
void serviceConnected(ServiceConnection conn) {
Log.debug("OSCAR service connected: "+conn.toString());
services.add(conn);
}
......@@ -348,14 +352,27 @@ public class OSCARSession extends TransportSession {
}
void serviceReady(ServiceConnection conn) {
Log.debug("OSCAR service ready: "+conn.toString());
snacMgr.dequeueSnacs(conn);
}
void serviceDied(ServiceConnection conn) {
Log.debug("OSCAR service died: "+conn.toString());
services.remove(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.
*
......
......@@ -22,6 +22,7 @@ import net.kano.joscar.snac.SnacPacketEvent;
import net.kano.joscar.snac.SnacResponseEvent;
import net.kano.joscar.net.ClientConnEvent;
import net.kano.joscar.net.ConnDescriptor;
import org.jivesoftware.util.Log;
/**
* Represents a connection to a particular OSCAR service.
......@@ -44,6 +45,7 @@ public class ServiceConnection extends BasicFlapConnection {
}
protected void handleStateChange(ClientConnEvent e) {
Log.debug("OSCAR service state change from "+e.getOldState()+" to "+e.getNewState());
if (e.getNewState() == ClientFlapConn.STATE_FAILED) {
oscarSession.serviceFailed(this);
} 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