/** * Close the agent session. The underlying connection will remain opened but the * stanza listeners that were added by this agent session will be removed. */ public void close() { connection.removeAsyncStanzaListener(packetListener); }
/** * Remove the stanza listener used for processing packet. */ protected void removeAsyncPacketListener() { if (packetListener != null) { getConnection().removeAsyncStanzaListener(packetListener); LOGGER.fine("JINGLE SESSION: REMOVE PACKET LISTENER"); } }
/** * Remove active stanza listeners needed for OMEMO. */ public void stopStanzaAndPEPListeners() { PepManager.getInstanceFor(connection()).removePepListener(deviceListUpdateListener); connection().removeAsyncStanzaListener(internalOmemoMessageStanzaListener); CarbonManager.getInstanceFor(connection()).removeCarbonCopyReceivedListener(internalOmemoCarbonCopyListener); }
conTwo.removeAsyncStanzaListener(stanzaListener);
@Override protected void doStop() { if (this.xmppConnection != null) { this.xmppConnection.removeAsyncStanzaListener(this.stanzaListener); } }
conOne.removeAsyncStanzaListener(presenceListener);
/** * Register stanza listeners needed for OMEMO. * This method is called automatically in the constructor and should only be used to restore the previous state * after {@link #stopStanzaAndPEPListeners()} was called. */ public void resumeStanzaAndPEPListeners() { PepManager pepManager = PepManager.getInstanceFor(connection()); CarbonManager carbonManager = CarbonManager.getInstanceFor(connection()); // Remove listeners to avoid them getting added twice connection().removeAsyncStanzaListener(internalOmemoMessageStanzaListener); carbonManager.removeCarbonCopyReceivedListener(internalOmemoCarbonCopyListener); pepManager.removePepListener(deviceListUpdateListener); // Add listeners pepManager.addPepListener(deviceListUpdateListener); connection().addAsyncStanzaListener(internalOmemoMessageStanzaListener, omemoMessageStanzaFilter); carbonManager.addCarbonCopyReceivedListener(internalOmemoCarbonCopyListener); }
conTwo.removeAsyncStanzaListener(stanzaListener);
@Override protected void doStop() { if (this.xmppConnection != null) { this.xmppConnection.removeAsyncStanzaListener(this.stanzaListener); } }
@Test /* * Should add/remove StanzaListener when endpoint started/stopped */ public void testLifecycle() { final Set<StanzaListener> packetListSet = new HashSet<>(); XMPPConnection connection = mock(XMPPConnection.class); ChatMessageListeningEndpoint endpoint = new ChatMessageListeningEndpoint(connection); willAnswer(invocation -> { packetListSet.add(invocation.getArgument(0)); return null; }).given(connection) .addAsyncStanzaListener(any(StanzaListener.class), isNull()); willAnswer(invocation -> { packetListSet.remove(invocation.getArgument(0)); return null; }).given(connection) .removeAsyncStanzaListener(any(StanzaListener.class)); assertEquals(0, packetListSet.size()); endpoint.setOutputChannel(new QueueChannel()); endpoint.setBeanFactory(mock(BeanFactory.class)); endpoint.afterPropertiesSet(); endpoint.start(); assertEquals(1, packetListSet.size()); endpoint.stop(); assertEquals(0, packetListSet.size()); }
public void uninstall() { SparkManager.getConnection().removeAsyncStanzaListener(this); }
/** * Leaves a ChatRoom. Leaving a chat room does everything but close the room itself. * * @param room the room to leave. */ public void leaveChatRoom(ChatRoom room) { // Notify that the chatroom has been left. fireChatRoomLeft(room); room.leaveChatRoom(); final StanzaListener listener = presenceMap.get(room.getRoomname()); if (listener != null && SparkManager.getConnection().isConnected()) { SparkManager.getConnection().removeAsyncStanzaListener(listener); } }
public void closeChatRoom() { // If already closed, don't bother. if (!active) { return; } super.closeChatRoom(); removeListeners(); SparkManager.getChatManager().removeChat(this); SparkManager.getConnection().removeAsyncStanzaListener(this); active = false; vcardPanel = null; this.removeAll(); }
/** * Have the user leave this chat room and then close it. */ @Override public void closeChatRoom() { // Specify the end time. super.closeChatRoom(); // Remove Listener SparkManager.getConnection().removeAsyncStanzaListener( this ); final ChatContainer container = SparkManager.getChatManager().getChatContainer(); container.leaveChatRoom( this ); container.closeTab( this ); }
/** * Removes the ChatRoom resources. * * @param room the room to remove. */ private void cleanupChatRoom(ChatRoom room) { if (room.isActive()) { room.leaveChatRoom(); room.closeChatRoom(); } final StanzaListener listener = presenceMap.get(room.getRoomname()); if (listener != null) { SparkManager.getConnection().removeAsyncStanzaListener(listener); } fireChatRoomClosed(room); room.removeMessageListener(this); // Remove mappings presenceMap.remove(room.getRoomname()); chatRoomList.remove(room); room.getChatInputEditor().removeKeyListener(this); // Clear all Text :) room.getTranscriptWindow().cleanup(); }
}).when(connection).removeAsyncStanzaListener(Mockito.any(StanzaListener.class));
SparkManager.getConnection().removeAsyncStanzaListener( this );
SparkManager.getConnection().removeAsyncStanzaListener(packetListener);