public void listen(XMPPPacketListener packetListener){ xmppConnection.addPacketListener(packetListener,packetFilter); }
private void init() { // Listens for all roster exchange packets and fire the roster exchange listeners. packetListener = new PacketListener() { public void processPacket(Packet packet) { Message message = (Message) packet; RosterExchange rosterExchange = (RosterExchange) message.getExtension("x", "jabber:x:roster"); // Fire event for roster exchange listeners fireRosterExchangeListeners(message.getFrom(), rosterExchange.getRosterEntries()); }; }; con.addPacketListener(packetListener, packetFilter); }
public void listen(XMPPPacketListener packetListener){ xmppConnection.addPacketListener(packetListener,packetFilter); }
/** * Adds a packet listener that will be notified of any new Presence packets * sent to the group chat. Using a listener is a suitable way to know when the list * of participants should be re-loaded due to any changes. * * @param listener a packet listener that will be notified of any presence packets * sent to the group chat. */ public void addParticipantListener(PacketListener listener) { connection.addPacketListener(listener, presenceFilter); connectionListeners.add(listener); }
private void init() { // Listens for all message event packets and fire the proper message event listeners. packetListener = new PacketListener() { public void processPacket(Packet packet) { Message message = (Message) packet; MessageEvent messageEvent = (MessageEvent) message.getExtension("x", "jabber:x:event"); if (messageEvent.isMessageEventRequest()) { // Fire event for requests of message events for (Iterator it = messageEvent.getEventTypes(); it.hasNext();) fireMessageEventRequestListeners( message.getFrom(), message.getPacketID(), ((String) it.next()).concat("NotificationRequested")); } else // Fire event for notifications of message events for (Iterator it = messageEvent.getEventTypes(); it.hasNext();) fireMessageEventNotificationListeners( message.getFrom(), messageEvent.getPacketID(), ((String) it.next()).concat("Notification")); }; }; con.addPacketListener(packetListener, packetFilter); }
/** * Adds a packet listener that will be notified of any new Presence packets * sent to the group chat. Using a listener is a suitable way to know when the list * of occupants should be re-loaded due to any changes. * * @param listener a packet listener that will be notified of any presence packets * sent to the group chat. */ public void addParticipantListener(PacketListener listener) { connection.addPacketListener(listener, presenceFilter); connectionListeners.add(listener); }
/** * Adds a packet listener that will be notified of any new messages in the * group chat. Only "group chat" messages addressed to this group chat will * be delivered to the listener. If you wish to listen for other packets * that may be associated with this group chat, you should register a * PacketListener directly with the XMPPConnection with the appropriate * PacketListener. * * @param listener a packet listener. */ public void addMessageListener(PacketListener listener) { connection.addPacketListener(listener, messageFilter); connectionListeners.add(listener); }
/** * Adds a packet listener that will be notified of any new messages in the * group chat. Only "group chat" messages addressed to this group chat will * be delivered to the listener. If you wish to listen for other packets * that may be associated with this group chat, you should register a * PacketListener directly with the XMPPConnection with the appropriate * PacketListener. * * @param listener a packet listener. */ public void addMessageListener(PacketListener listener) { connection.addPacketListener(listener, messageFilter); connectionListeners.add(listener); }
/** * Adds a packet listener that will be notified of any new messages in the * chat. * * @param listener a packet listener. */ public void addMessageListener(PacketListener listener) { connection.addPacketListener(listener, messageFilter); // Keep track of the listener so that we can manually deliver extra // messages to it later if needed. synchronized (listeners) { listeners.add(new WeakReference(listener)); } }
private IBBInputStream(String streamID, PacketFilter dataFilter, PacketFilter closeFilter) { this.streamID = streamID; this.dataCollector = connection.createPacketCollector(dataFilter); connection.addPacketListener(this, closeFilter); this.bufferPointer = -1; }
/** * This handles the chat listener. We can't simply listen to chats for some reason, and instead * have to grab the chats from the packets. The other listeners work properly in SMACK */ public void setupListeners() { /* * This is the actual code that handles what happens with XMPP users */ packetListener = new XMPPPacketListener(this); // PacketFilter filter = new MessageTypeFilter(Message.Type.chat); connection.addPacketListener(packetListener, null); }
@Override public void addPacketListener(PacketListener listener) { PacketFilter filter = createPacketFilter(); connection.addPacketListener(listener, filter); }
public void addPacketListener(PacketListener packetListener, PacketFilter packetFilter) { getConnection().addPacketListener(packetListener, packetFilter); }
private void processMessages() { final PacketFilter filter = new PacketTypeFilter(Message.class); final PacketListener myListener = new PacketListener() { @Override public void processPacket(final Packet packet) { final Message msg = (Message) packet; final String id = msg.getPacketID(); log.info("Checking message ID: {}", id); if (loggedOut.get()) { log.warn("Got a message while logged out?"); return; } if (sentMessageIds.contains(id)) { log.warn("Message is from us!!"); // This is a little silly in that we're sending a // message back to ourselves, but this signals to the // client thread right away that the invite has failed. final Message error = newError(msg); xmppConnection.sendPacket(error); } else { exec.execute(new PacketProcessor(msg)); } } }; // Register the listener. this.xmppConnection.addPacketListener(myListener, filter); }
void addListener(String connectionID, XMPPConnection connection, XmppActivityHandle handle, Collection<Class<?>> packetFilters) { // create listener XmppConnectionListener listener = new XmppConnectionListener(this,connectionID,handle); // add packet filters if packetFilters is not null if (packetFilters == null) { connection.addPacketListener(listener, null); } else { for(Class<?> clazz : packetFilters) { connection.addPacketListener(listener, new PacketTypeFilter(clazz)); } } // add connection listener connection.addConnectionListener(listener); }
/** * Creates a new roster. * * @param connection an XMPP connection. */ Roster(final XMPPConnection connection) { this.connection = connection; groups = new Hashtable(); unfiledEntries = new ArrayList(); entries = new ArrayList(); rosterListeners = new ArrayList(); presenceMap = new HashMap(); // Listen for any roster packets. PacketFilter rosterFilter = new PacketTypeFilter(RosterPacket.class); connection.addPacketListener(new RosterPacketListener(), rosterFilter); // Listen for any presence packets. PacketFilter presenceFilter = new PacketTypeFilter(Presence.class); connection.addPacketListener(new PresencePacketListener(), presenceFilter); }
private void connect() throws XMPPException { connection = kenai.getXMPPConnection(); connection.addPacketListener(new PacketL(), new MessageTypeFilter(Type.chat)); }
private void initListeners() { listeners = new ArrayList(); connection.addPacketListener(new PacketListener() { public void processPacket(Packet packet) { fireNewRequest((StreamInitiation) packet); } }, new AndFilter(new PacketTypeFilter(StreamInitiation.class), new IQTypeFilter(IQ.Type.SET))); }
private void xmppConnect() throws KenaiException { firePropertyChange(new PropertyChangeEvent(this, PROP_XMPP_LOGIN_STARTED, null, null)); synchronized (this) { xmppConnection = new XMPPConnection(getUrl().getHost()); packetListener = new KenaiUser.KenaiPacketListener(); try { xmppConnection.removePacketListener(packetListener); xmppConnection.connect(); xmppConnection.addPacketListener(packetListener, new PacketTypeFilter(Presence.class)); xmppConnection.login(auth.getUserName(), new String(auth.getPassword()), "NetBeans"); //NOI18N } catch (XMPPException xMPPException) { xmppConnection = null; firePropertyChange(new PropertyChangeEvent(this, PROP_XMPP_LOGIN_FAILED, null, null)); throw new KenaiException(xMPPException); } catch (IllegalStateException ise) { xmppConnection = null; firePropertyChange(new PropertyChangeEvent(this, PROP_XMPP_LOGIN_FAILED, null, null)); throw new KenaiException(ise); } } firePropertyChange(new PropertyChangeEvent(this, PROP_XMPP_LOGIN, null, xmppConnection)); }
private void setUpConnection(XMPPConnection newConn) { conn = newConn; conn.setPacketReplyTimeout(Integer.parseInt(getPacketReplyTimeout())); conn.setFromMode(getFromMode()); if (log.isDebugEnabled()) { conn.addConnectionListener(new Loggers.LogConn(conn)); conn.addPacketListener(new Loggers.LogRecv(conn), new AndFilter()); conn.addPacketSendingListener(new Loggers.LogSent(conn), new AndFilter()); } for (AbstractXMPPAction action : actions.values()) { if (action instanceof PacketListener) { conn.addPacketListener((PacketListener) action, action.getPacketFilter()); } if (action instanceof ConnectionListener) { conn.addConnectionListener((ConnectionListener) action); } } }