org.jivesoftware.smackx.chatstates.ChatStateManager Java Examples
The following examples show how to use
org.jivesoftware.smackx.chatstates.ChatStateManager.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EligibleForChatMarkerFilter.java From Smack with Apache License 2.0 | 6 votes |
/** * From XEP-0333, Protocol Format: The Chat Marker MUST have an 'id' which is the 'id' of the * message being marked.<br> * In order to make Chat Markers works together with XEP-0085 as it said in * 8.5 Interaction with Chat States, only messages with <code>active</code> chat * state are accepted. * * @param message to be analyzed. * @return true if the message contains a stanza Id. * @see <a href="http://xmpp.org/extensions/xep-0333.html">XEP-0333: Chat Markers</a> */ @Override public boolean accept(Stanza message) { if (!message.hasStanzaIdSet()) { return false; } if (super.accept(message)) { ExtensionElement extension = message.getExtension(ChatStateManager.NAMESPACE); String chatStateElementName = extension.getElementName(); ChatState state; try { state = ChatState.valueOf(chatStateElementName); return state == ChatState.active; } catch (Exception ex) { return false; } } return true; }
Example #2
Source File: ChatStateIntegrationTest.java From Smack with Apache License 2.0 | 6 votes |
@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); }
Example #3
Source File: ChatManager.java From Spark with Apache License 2.0 | 5 votes |
/** * Create a new instance of ChatManager. */ private ChatManager() { chatContainer = UIComponentRegistry.createChatContainer(); // Add Default Chat Room Decorator addSparkTabHandler(new DefaultTabHandler()); // Add a Message Handler ChatStateManager chatStateManager = ChatStateManager.getInstance(SparkManager.getConnection()); chatStateManager.addChatStateListener(smackChatStateListener); }
Example #4
Source File: ChatStateIntegrationTest.java From Smack with Apache License 2.0 | 4 votes |
@AfterClass public void cleanup() { ChatStateManager manTwo = ChatStateManager.getInstance(conTwo); manTwo.removeChatStateListener(this::composingListener); manTwo.removeChatStateListener(this::activeListener); }