/** * Handles incoming presence packets and maps jids to node#ver strings. * * @param packet the incoming presence <tt>Packet</tt> to be handled * @see PacketListener#processPacket(Packet) */ public void processPacket(Packet packet) { CapsPacketExtension ext = (CapsPacketExtension) packet.getExtension(CapsPacketExtension.ELEMENT_NAME, CapsPacketExtension.NAMESPACE); /* * Before Version 1.4 of XEP-0115: Entity Capabilities, the 'ver' * attribute was generated differently and the 'hash' attribute was * absent. The 'ver' attribute in Version 1.3 represents the * specific version of the client and thus does not provide a way to * validate the DiscoverInfo sent by the client. If * EntityCapsManager receives no 'hash' attribute, it will assume * the legacy format and will not cache it because the DiscoverInfo * to be received from the client later on will not be trustworthy. */ String hash = ext.getHash(); /* Google Talk web does not set hash but we need it to be cached */ if (hash == null) hash = ""; if (hash != null) { // Check it the packet indicates that the user is online. We // will use this information to decide if we're going to send // the discover info request. boolean online = (packet instanceof Presence) && ((Presence) packet).isAvailable(); if (online) { addUserCapsNode( packet.getFrom(), ext.getNode(), hash, ext.getVersion(), ext.getExtensions(), online); } else { removeUserCapsNode(packet.getFrom()); } } }
/** @param packet */ public void processPacket(Packet packet) { PresenceIndicator.getDefault() .label .setText( KenaiUser.getOnlineUserCount() > 0 ? KenaiUser.getOnlineUserCount() - 1 + "" : ""); // NOI18N PresenceIndicator.getDefault() .label .setToolTipText( NbBundle.getMessage( PresenceIndicator.class, "LBL_LoggedIn_Tooltip", KenaiUser.getOnlineUserCount() > 0 ? KenaiUser.getOnlineUserCount() - 1 : "")); for (MultiUserChat muc : KenaiConnection.getDefault( KenaiConnection.getKenai(StringUtils.parseBareAddress(packet.getFrom()))) .getChats()) { String chatName = StringUtils.parseName(muc.getRoom()); assert chatName != null : "muc.getRoom() = " + muc.getRoom(); // NOI18N ChatNotifications.getDefault() .getMessagingHandle(KenaiConnection.getKenaiProject(muc)) .setOnlineCount(muc.getOccupantsCount()); } }
/** Accept requests from a given TCP port */ public void run() { try { if (logger.isDebugEnabled()) { logger.debug("Processing XMPP packet from: " + packet.getFrom()); } MuleMessage message = createMuleMessage(packet, endpoint.getEncoding()); MuleMessage returnMessage = routeMessage(message, endpoint.isSynchronous()); if (returnMessage != null && packet instanceof Message) { returnMessage.applyTransformers(connector.getDefaultResponseTransformers()); Packet result = (Packet) returnMessage.getPayload(); // xmppConnection.sendPacket(result); } } catch (Exception e) { handleException(e); } }
public void processPacket(ConnectionThread connectionThread, Packet packet) { if (!managedConnections.contains(connectionThread)) return; ConnectionItem connectionItem = connectionThread.getConnectionItem(); if (packet instanceof IQ && connectionItem instanceof AccountItem) { IQ iq = (IQ) packet; String packetId = iq.getPacketID(); if (packetId != null && (iq.getType() == Type.RESULT || iq.getType() == Type.ERROR)) { String account = ((AccountItem) connectionItem).getAccount(); RequestHolder requestHolder = requests.remove(account, packetId); if (requestHolder != null) { if (iq.getType() == Type.RESULT) requestHolder.getListener().onReceived(account, packetId, iq); else requestHolder.getListener().onError(account, packetId, iq); } } } for (OnPacketListener listener : Application.getInstance().getManagers(OnPacketListener.class)) listener.onPacket(connectionItem, Jid.getBareAddress(packet.getFrom()), packet); }
private void doProcessPacket(Packet packet) { final Message message = ((Message) packet); if (message.getType() == Message.Type.ERROR) { UIUtil.invokeLater( () -> { String from = (message.getFrom() != null) ? getMsg("from.0.lf", message.getFrom()) : ""; LOG.warn( getMsg( "jabber.error.text", from, (message.getError() == null ? "N/A" : message.getError().toString()))); }); return; } if (myIgnoreList.isIgnored(packet.getFrom())) { return; } Element element = null; for (PacketExtension o : message.getExtensions()) { if (o instanceof JDOMExtension) { element = ((JDOMExtension) o).getElement(); } } if (element != null && !RESPONSE.equals(element.getName())) { processAndSendResponse(element, message); } else if (element == null && message.getBody() != null) { // Some simple Jabber Message MessageEvent event = EventFactory.createMessageEvent( JabberTransport.this, getFrom(message), message.getBody()); if (message.getThread() != null) { myUser2Thread.put(getFrom(message), message.getThread()); } getBroadcaster().fireEvent(event); } }