public void interceptPacket(Packet packet) { Presence presence = (Presence) packet; // Check if user is joining a room if (Presence.Type.available == presence.getType() && presence.getExtension("x", "http://jabber.org/protocol/muc") != null) { // Add extension that indicates that user wants to be a deaf occupant packet.addExtension(new DeafExtension()); } }
private static void sendThroughService( Connection connection, Packet packet, List<String> to, List<String> cc, List<String> bcc, String replyTo, String replyRoom, boolean noReply, String serviceAddress) { // Create multiple recipient extension MultipleAddresses multipleAddresses = new MultipleAddresses(); if (to != null) { for (Iterator<String> it = to.iterator(); it.hasNext(); ) { String jid = it.next(); multipleAddresses.addAddress(MultipleAddresses.TO, jid, null, null, false, null); } } if (cc != null) { for (Iterator<String> it = cc.iterator(); it.hasNext(); ) { String jid = it.next(); multipleAddresses.addAddress(MultipleAddresses.CC, jid, null, null, false, null); } } if (bcc != null) { for (Iterator<String> it = bcc.iterator(); it.hasNext(); ) { String jid = it.next(); multipleAddresses.addAddress(MultipleAddresses.BCC, jid, null, null, false, null); } } if (noReply) { multipleAddresses.setNoReply(); } else { if (replyTo != null && replyTo.trim().length() > 0) { multipleAddresses.addAddress(MultipleAddresses.REPLY_TO, replyTo, null, null, false, null); } if (replyRoom != null && replyRoom.trim().length() > 0) { multipleAddresses.addAddress( MultipleAddresses.REPLY_ROOM, replyRoom, null, null, false, null); } } // Set the multiple recipient service address as the target address packet.setTo(serviceAddress); // Add extension to packet packet.addExtension(multipleAddresses); // Send the packet connection.sendPacket(packet); }