chatManager.addPairChatChangedHandler(this);
}
@Override
public void onPairChatChanged(final PairChatChangedEvent event) {
final PairChat chat = event.getChat();
display.print("CHAT CHANGED " + chat.getURI() + " - " + event.getChangeType(), Style.event);
if (event.is(ChangeType.created)) {
chat.addChatStateChangedHandler(false, new ChatStateChangedEvent.Handler() {
@Override
public void onChatStateChanged(final ChatStateChangedEvent event) {
display.print("CHAT STATE " + chat.getURI() + " changed: " + event.getState(), Style.event);
}
});
display.print("CHAT STATE " + chat.getURI() + " - " + chat.getChatState(), Style.event);
chat.addErrorHandler(new ErrorEvent.Handler() {
@Override
public void onError(final ErrorEvent event) {
final String stanza = event.getStanza() != null ? event.getStanza().toString() : "(no stanza)";
display.print("CHAT ERROR " + chat.getURI() + ": " + event.getErrorType() + "- " + event.getDescription() + ": " + stanza, Style.error);
}
});
}
}