Search in sources :

Example 1 with ChatStateManager

use of org.jivesoftware.smackx.chatstates.ChatStateManager 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)

Example 2 with ChatStateManager

use of org.jivesoftware.smackx.chatstates.ChatStateManager in project Smack by igniterealtime.

the class ChatStateIntegrationTest method cleanup.

@AfterClass
public void cleanup() {
    ChatStateManager manTwo = ChatStateManager.getInstance(conTwo);
    manTwo.removeChatStateListener(this::composingListener);
    manTwo.removeChatStateListener(this::activeListener);
}
Also used : ChatStateManager(org.jivesoftware.smackx.chatstates.ChatStateManager) AfterClass(org.igniterealtime.smack.inttest.annotations.AfterClass)

Aggregations

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