switch (msg.getPacketType()) {
case PacketType.START:
if (suid != null) {
boolean bad = false;
Session s= Session.getSession(suid);
if (s != null && !s.getConnectionUID().equals(con.getConnectionUID()))
bad = true;
assert s != null;
// OK .. the client should never be sending us
// a bad session ID, but in reconnect it sometimes
// does
// handle it gracefully if the client does the
// wrong thing
if (s == null || bad ) {
logger.log(Logger.INFO,"Internal Error: received "
+ "bad session id " + suid
+ " when starting session");
if (bad) {
logger.log(logger.INFO,"Session " + suid +
" is bad because "
+ " it is from a different connection "
+ " [owning,current]=[" + s.getConnectionUID()
+ "," + con.getConnectionUID() + "]");
}
status = Status.ERROR;
reason = "received bad session id " + suid +", session "+s+
" when starting session";
} else {
s.resume("START_STOP");
}
} else {
con.startConnection();
}
break;
case PacketType.STOP:
if (suid != null) {
boolean bad = false;
Session s= Session.getSession(suid);
if (s != null && !s.getConnectionUID().equals(con.getConnectionUID()))
bad = true;
assert s != null;
// OK .. the client should never be sending us
// a bad session ID, but in reconnect it sometimes
// does
// handle it gracefully if the client does the
// wrong thing
if (s == null || bad) {
logger.log(Logger.INFO,"Internal Error: received "
+ "bad session id " + suid
+ " when stopping session");
if (bad) {
logger.log(logger.INFO,"Session " + suid +
" is bad because "
+ " it is from a different connection "
+ " [owning,current]=[" + s.getConnectionUID()
+ "," + con.getConnectionUID() + "]");
}
status = Status.ERROR;
reason = "received bad session id " + suid +", session "+s+
" when stopping session";
} else {
s.pause("START_STOP");
}
} else {
con.stopConnection();
}
Packet pkt = new Packet(con.useDirectBuffers());