}
break;
case AUTHENTICATE:
case READY:
if (event.isEndElement()) {
final EndElement element = event.asEndElement();
if (STREAM_NAME.equals(element.getName())) {
Channels.disconnect(ctx.getChannel());
return;
}
}
break;
case DISCONNECTED:
throw new Exception("received DISCONNECTED");
}
}
else if (e.getMessage() instanceof XMLElement) {
final XMLElement element = (XMLElement) e.getMessage();
switch (status) {
case AUTHENTICATE:
if (!"handshake".equals(element.getTagName()))
throw new Exception("expected handshake");
status = Status.READY;
System.out.println("logged in");
ctx.getPipeline().get(XMPPStreamHandler.class).loggedIn();