Java Code Examples for org.xmpp.packet.Packet#setFrom()
The following examples show how to use
org.xmpp.packet.Packet#setFrom() .
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: TransportHandler.java From Openfire with Apache License 2.0 | 6 votes |
@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); } } }
Example 2
Source File: LocalMUCRoom.java From Openfire with Apache License 2.0 | 5 votes |
@Override public void sendPrivatePacket(Packet packet, MUCRole senderRole) throws NotFoundException, ForbiddenException { switch (senderRole.getRole()) { // intended fall-through case none: throw new ForbiddenException(); default: case visitor: if (canSendPrivateMessage().equals( "participants" )) throw new ForbiddenException(); case participant: if (canSendPrivateMessage().equals( "moderators" )) throw new ForbiddenException(); case moderator: if (canSendPrivateMessage().equals( "none" )) throw new ForbiddenException(); } String resource = packet.getTo().getResource(); List<MUCRole> occupants = occupantsByNickname.get(resource.toLowerCase()); if (occupants == null || occupants.size() == 0) { throw new NotFoundException(); } for (MUCRole occupant : occupants) { packet.setFrom(senderRole.getRoleAddress()); occupant.send(packet); if(packet instanceof Message) { Message message = (Message) packet; MUCEventDispatcher.privateMessageRecieved(occupant.getUserAddress(), senderRole.getUserAddress(), message); } } }
Example 3
Source File: AuditorImpl.java From Openfire with Apache License 2.0 | 5 votes |
public AuditPacket(Packet packet, Session session) { element = docFactory.createElement("packet", "http://www.jivesoftware.org"); creationDate = new Date(); if (session != null && session.getStreamID() != null) { element.addAttribute("streamID", session.getStreamID().toString()); } switch (session == null ? 0 : session.getStatus()) { case Session.STATUS_AUTHENTICATED: element.addAttribute("status", "auth"); break; case Session.STATUS_CLOSED: element.addAttribute("status", "closed"); break; case Session.STATUS_CONNECTED: element.addAttribute("status", "connected"); // This is a workaround. Since we don't want to have an incorrect FROM attribute // value we need to clean up the FROM attribute. The FROM attribute will contain // an incorrect value since we are setting a fake JID until the user actually // authenticates with the server. packet.setFrom((String) null); break; default: element.addAttribute("status", "unknown"); break; } element.addAttribute("timestamp", auditFormat.format(creationDate)); element.add(packet.getElement()); }
Example 4
Source File: DefaultXmppDevice.java From onos with Apache License 2.0 | 5 votes |
@Override public void sendPacket(Packet packet) { packet.setTo(this.deviceId.getJid()); packet.setFrom(new JID(XmppConstants.SERVER_JID)); Preconditions.checkNotNull(packet); if (this.session.isActive()) { this.session.sendPacket(packet); } else { logger.warn("Dropping XMPP packets for switch {} because channel is not connected: {}", this.deviceId, packet); } }
Example 5
Source File: DefaultXmppDevice.java From onos with Apache License 2.0 | 5 votes |
@Override public void sendError(PacketError packetError) { Packet packet = new IQ(); packet.setTo(this.deviceId.getJid()); packet.setFrom(new JID(XmppConstants.SERVER_JID)); packet.setError(packetError); this.session.sendPacket(packet); }