@Override public void send(Packet packet) { if (packet == null) { return; } packet.setTo(user.getAddress()); router.route(packet); }
/** * Broadcasts the given data to all connected sessions for a particular * user. Excellent for updating all connected resources for users such as * roster pushes. * * @param username the user to send the boradcast to. * @param packet the packet to be broadcast. * @throws PacketException if a packet exception occurs. */ public void userBroadcast(String username, Packet packet) throws PacketException { // TODO broadcast to ALL sessions of the user and not only available for (JID address : routingTable.getRoutes(new JID(username, serverName, null), null)) { packet.setTo(address); routingTable.routePacket(address, packet, true); } }
localBroadcast.setTo(jid); packetRouter.route(localBroadcast);
@Override public void process(Packet packet) throws UnauthorizedException, PacketException { boolean handled = false; String host = packet.getTo().getDomain(); for (Channel<Packet> channel : transports.values()) { if (channel.getName().equalsIgnoreCase(host)) { channel.add(packet); handled = true; } } if (!handled) { JID recipient = packet.getTo(); JID sender = packet.getFrom(); packet.setError(PacketError.Condition.remote_server_timeout); packet.setFrom(recipient); packet.setTo(sender); try { deliverer.deliver(packet); } catch (PacketException e) { Log.error(LocaleUtils.getLocalizedString("admin.error"), e); } } }
/** * Generate a conflict packet to indicate that the nickname being requested/used is already in * use by another user. * * @param packet the packet to be bounced. * @param error the reason why the operation failed. */ private void sendErrorPacket(Packet packet, PacketError.Condition error) { if (packet instanceof IQ) { IQ reply = IQ.createResultIQ((IQ) packet); reply.setChildElement(((IQ) packet).getChildElement().createCopy()); reply.setError(error); router.route(reply); } else { Packet reply = packet.createCopy(); reply.setError(error); reply.setFrom(packet.getTo()); reply.setTo(packet.getFrom()); router.route(reply); } }
/** * Broadcasts the given data to all connected sessions for a particular * user. Excellent for updating all connected resources for users such as * roster pushes. * * @param username the user to send the boradcast to. * @param packet the packet to be broadcast. * @throws PacketException if a packet exception occurs. */ public void userBroadcast(String username, Packet packet) throws PacketException { // TODO broadcast to ALL sessions of the user and not only available for (JID address : routingTable.getRoutes(new JID(username, serverName, null), null)) { packet.setTo(address); routingTable.routePacket(address, packet, true); } }
localBroadcast.setTo(jid); packetRouter.route(localBroadcast);
@Override public void send(Packet packet) { if (packet == null) { return; } packet.setTo(user.getAddress()); if (session != null && session.getStatus() == Session.STATUS_AUTHENTICATED) { // Send the packet directly to the local user session session.process(packet); } else { router.route(packet); } }
@Override public void process(Packet packet) throws UnauthorizedException, PacketException { boolean handled = false; String host = packet.getTo().getDomain(); for (Channel<Packet> channel : transports.values()) { if (channel.getName().equalsIgnoreCase(host)) { channel.add(packet); handled = true; } } if (!handled) { JID recipient = packet.getTo(); JID sender = packet.getFrom(); packet.setError(PacketError.Condition.remote_server_timeout); packet.setFrom(recipient); packet.setTo(sender); try { deliverer.deliver(packet); } catch (PacketException e) { Log.error(LocaleUtils.getLocalizedString("admin.error"), e); } } }
/** * Generate a conflict packet to indicate that the nickname being requested/used is already in * use by another user. * * @param packet the packet to be bounced. * @param error the reason why the operation failed. */ private void sendErrorPacket(Packet packet, PacketError.Condition error) { if (packet instanceof IQ) { IQ reply = IQ.createResultIQ((IQ) packet); reply.setChildElement(((IQ) packet).getChildElement().createCopy()); reply.setError(error); router.route(reply); } else { Packet reply = packet.createCopy(); reply.setError(error); reply.setFrom(packet.getTo()); reply.setTo(packet.getFrom()); router.route(reply); } }