@Test public void shouldStartStateNegotiation() { chat.send(new Message("test message")); chat.send(new Message("test message")); session.verifySent( "<message><active xmlns='http://jabber.org/protocol/chatstates' /></message>"); }
@Test public void shouldStartStateNegotiationOnce() { chat.send(new Message("message1")); chat.send(new Message("message2")); session.verifySent("<message><body>message1</body><active /></message>"); session.verifySent("<message><body>message2</body></message>"); session.verifyNotSent("<message><body>message2</body><active /></message>"); }
@Override public void onModuleLoad() { createUI(); log("Example IM Chat"); String self = PageAssist.getMeta("emite.user"); log("Current user: "******"emite.chat"); log("Chat with user: "******"Current state: " + state); } }); final ChatManager chatManager = ginjector.getChatManager(); input.addChangeHandler( new ChangeHandler() { @Override public void onChange(ChangeEvent event) { String msg = input.getText(); log("Message sent: " + msg); Chat chat = chatManager.open(uri(user)); chat.send(new Message(msg)); input.setText(""); } }); Chat chat = chatManager.open(uri(user)); chat.addMessageReceivedHandler( new MessageHandler() { @Override public void onMessage(MessageEvent event) { log("Message received: " + event.getMessage().getBody()); } }); }
@Test public void shouldStartStateAfterNegotiation() { chat.send(new Message("test message")); session.receives( "<message from='other@domain/other' to='self@domain/res' type='chat'>" + "<active xmlns='http://jabber.org/protocol/chatstates'/></message>"); final Message message = new Message(MYSELF, OTHER, "test message"); message.addChild(ChatStateManager.ChatState.active.toString(), ChatStateManager.XMLNS); chatStateManager.setOwnState(ChatStateManager.ChatState.composing); session.verifySent( message.toString() + "<message from='self@domain/res' to='other@domain/other' type='chat'>" + "<composing xmlns='http://jabber.org/protocol/chatstates'/></message>"); }
public ChatPanel createChat(final ChatManager chatManager, final Chat chat) { final ChatPanel panel = new ChatPanel(); new ChatControl(chatManager, chat, panel); return addChat(chat.getURI().toString(), chat.getID(), panel); }