Search in sources :

Example 1 with Chat

use of org.jivesoftware.smack.chat2.Chat in project Smack by igniterealtime.

the class ChatStateIntegrationTest method testChatStateListeners.

@SmackIntegrationTest
public void testChatStateListeners() throws Exception {
    ChatStateManager manOne = ChatStateManager.getInstance(conOne);
    ChatStateManager manTwo = ChatStateManager.getInstance(conTwo);
    // Add chatState listeners.
    manTwo.addChatStateListener(this::composingListener);
    manTwo.addChatStateListener(this::activeListener);
    Chat chatOne = ChatManager.getInstanceFor(conOne).chatWith(conTwo.getUser().asEntityBareJid());
    // Test, if setCurrentState works and the chatState arrives
    manOne.setCurrentState(ChatState.composing, chatOne);
    composingSyncPoint.waitForResult(timeout);
    // Test, if the OutgoingMessageInterceptor successfully adds a chatStateExtension of "active" to
    // an outgoing chat message and if it arrives at the other side.
    Chat chat = ChatManager.getInstanceFor(conOne).chatWith(conTwo.getUser().asEntityBareJid());
    chat.send("Hi!");
    activeSyncPoint.waitForResult(timeout);
}
Also used : ChatStateManager(org.jivesoftware.smackx.chatstates.ChatStateManager) Chat(org.jivesoftware.smack.chat2.Chat) AbstractSmackIntegrationTest(org.igniterealtime.smack.inttest.AbstractSmackIntegrationTest) SmackIntegrationTest(org.igniterealtime.smack.inttest.annotations.SmackIntegrationTest)

Aggregations

AbstractSmackIntegrationTest (org.igniterealtime.smack.inttest.AbstractSmackIntegrationTest)1 SmackIntegrationTest (org.igniterealtime.smack.inttest.annotations.SmackIntegrationTest)1 Chat (org.jivesoftware.smack.chat2.Chat)1 ChatStateManager (org.jivesoftware.smackx.chatstates.ChatStateManager)1