Search in sources :

Example 1 with RosterExchange

use of org.jivesoftware.smackx.packet.RosterExchange in project ecf by eclipse.

the class RosterExchangeManager method send.

/**
 * Sends a roster to userID. All the entries of the roster will be sent to the
 * target user.
 *
 * @param roster the roster to send
 * @param targetUserID the user that will receive the roster entries
 */
public void send(Roster roster, String targetUserID) {
    // Create a new message to send the roster
    Message msg = new Message(targetUserID);
    // Create a RosterExchange Package and add it to the message
    RosterExchange rosterExchange = new RosterExchange(roster);
    msg.addExtension(rosterExchange);
    // Send the message that contains the roster
    con.sendPacket(msg);
}
Also used : RosterExchange(org.jivesoftware.smackx.packet.RosterExchange) Message(org.jivesoftware.smack.packet.Message)

Example 2 with RosterExchange

use of org.jivesoftware.smackx.packet.RosterExchange in project ecf by eclipse.

the class RosterExchangeManager method send.

/**
 * Sends a roster entry to userID.
 *
 * @param rosterEntry the roster entry to send
 * @param targetUserID the user that will receive the roster entries
 */
public void send(RosterEntry rosterEntry, String targetUserID) {
    // Create a new message to send the roster
    Message msg = new Message(targetUserID);
    // Create a RosterExchange Package and add it to the message
    RosterExchange rosterExchange = new RosterExchange();
    rosterExchange.addRosterEntry(rosterEntry);
    msg.addExtension(rosterExchange);
    // Send the message that contains the roster
    con.sendPacket(msg);
}
Also used : RosterExchange(org.jivesoftware.smackx.packet.RosterExchange) Message(org.jivesoftware.smack.packet.Message)

Example 3 with RosterExchange

use of org.jivesoftware.smackx.packet.RosterExchange in project ecf by eclipse.

the class RosterExchangeManager method init.

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);
}
Also used : Packet(org.jivesoftware.smack.packet.Packet) RosterExchange(org.jivesoftware.smackx.packet.RosterExchange) Message(org.jivesoftware.smack.packet.Message) PacketListener(org.jivesoftware.smack.PacketListener)

Example 4 with RosterExchange

use of org.jivesoftware.smackx.packet.RosterExchange in project ecf by eclipse.

the class RosterExchangeManager method send.

/**
 * Sends a roster group to userID. All the entries of the group will be sent to the
 * target user.
 *
 * @param rosterGroup the roster group to send
 * @param targetUserID the user that will receive the roster entries
 */
public void send(RosterGroup rosterGroup, String targetUserID) {
    // Create a new message to send the roster
    Message msg = new Message(targetUserID);
    // Create a RosterExchange Package and add it to the message
    RosterExchange rosterExchange = new RosterExchange();
    for (RosterEntry entry : rosterGroup.getEntries()) {
        rosterExchange.addRosterEntry(entry);
    }
    msg.addExtension(rosterExchange);
    // Send the message that contains the roster
    con.sendPacket(msg);
}
Also used : RosterExchange(org.jivesoftware.smackx.packet.RosterExchange) Message(org.jivesoftware.smack.packet.Message) RosterEntry(org.jivesoftware.smack.RosterEntry)

Aggregations

Message (org.jivesoftware.smack.packet.Message)4 RosterExchange (org.jivesoftware.smackx.packet.RosterExchange)4 PacketListener (org.jivesoftware.smack.PacketListener)1 RosterEntry (org.jivesoftware.smack.RosterEntry)1 Packet (org.jivesoftware.smack.packet.Packet)1