use of org.xmpp.packet.Presence in project Openfire by igniterealtime.
the class ClusterListener method cleanupDirectedPresences.
private void cleanupDirectedPresences(NodeID nodeID) {
// Remove traces of directed presences sent from node that is gone to entities hosted in this JVM
Map<String, Collection<String>> senders = nodePresences.remove(nodeID);
if (senders != null) {
for (Map.Entry<String, Collection<String>> entry : senders.entrySet()) {
String sender = entry.getKey();
Collection<String> receivers = entry.getValue();
for (String receiver : receivers) {
try {
Presence presence = new Presence(Presence.Type.unavailable);
presence.setFrom(sender);
presence.setTo(receiver);
XMPPServer.getInstance().getPresenceRouter().route(presence);
} catch (PacketException e) {
logger.error("Failed to cleanup directed presences", e);
}
}
}
}
}
use of org.xmpp.packet.Presence in project Openfire by igniterealtime.
the class RemotePacketExecution method readExternal.
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
recipient = (JID) ExternalizableUtil.getInstance().readSerializable(in);
int packetType = ExternalizableUtil.getInstance().readInt(in);
Element packetElement = (Element) ExternalizableUtil.getInstance().readSerializable(in);
switch(packetType) {
case 1:
packet = new IQ(packetElement, true);
break;
case 2:
packet = new Message(packetElement, true);
break;
case 3:
packet = new Presence(packetElement, true);
break;
}
}
use of org.xmpp.packet.Presence in project Openfire by igniterealtime.
the class BOSConnection method handleSnacPacket.
@Override
protected void handleSnacPacket(SnacPacketEvent e) {
// Log.debug("OSCAR bos snac packet received: "+e);
super.handleSnacPacket(e);
SnacCommand cmd = e.getSnacCommand();
if (cmd instanceof ServerReadyCmd) {
request(new ParamInfoRequest());
request(new LocRightsRequest());
request(new SsiRightsRequest());
request(new SsiDataRequest());
} else if (cmd instanceof BuddyAddedYouCmd) {
BuddyAddedYouCmd bay = (BuddyAddedYouCmd) cmd;
Presence p = new Presence();
p.setType(Presence.Type.subscribe);
p.setTo(getMainSession().getJID());
p.setFrom(getMainSession().getTransport().convertIDToJID(bay.getUin()));
getMainSession().getTransport().sendPacket(p);
} else if (cmd instanceof BuddyAuthRequest) {
BuddyAuthRequest bar = (BuddyAuthRequest) cmd;
Presence p = new Presence();
p.setType(Presence.Type.subscribe);
p.setTo(getMainSession().getJID());
p.setFrom(getMainSession().getTransport().convertIDToJID(bar.getScreenname()));
getMainSession().getTransport().sendPacket(p);
// Auto-accept auth request. (for now)
// TODO: Evaluate handling this in a non-automated fashion.
request(new AuthReplyCmd(bar.getScreenname(), null, true));
} else if (cmd instanceof AuthReplyCmd) {
AuthReplyCmd ar = (AuthReplyCmd) cmd;
if (ar.isAccepted()) {
Presence p = new Presence();
p.setType(Presence.Type.subscribed);
p.setTo(getMainSession().getJID());
p.setFrom(getMainSession().getTransport().convertIDToJID(ar.getSender()));
getMainSession().getTransport().sendPacket(p);
} else {
Presence p = new Presence();
p.setType(Presence.Type.unsubscribed);
p.setTo(getMainSession().getJID());
p.setFrom(getMainSession().getTransport().convertIDToJID(ar.getSender()));
getMainSession().getTransport().sendPacket(p);
}
} else if (cmd instanceof ModifyItemsCmd) {
ModifyItemsCmd mic = (ModifyItemsCmd) cmd;
List<SsiItem> items = mic.getItems();
for (SsiItem item : items) {
SsiItemObj obj = itemFactory.getItemObj(item);
if (obj instanceof BuddyItem) {
BuddyItem bi = (BuddyItem) obj;
Log.debug("AIM got buddy item " + bi);
getMainSession().getSsiHierarchy().gotBuddy(bi);
} else if (obj instanceof GroupItem) {
GroupItem gi = (GroupItem) obj;
Log.debug("AIM got group item " + gi);
getMainSession().getSsiHierarchy().gotGroup(gi);
}
}
}
}
use of org.xmpp.packet.Presence in project Openfire by igniterealtime.
the class YahooListener method contactAcceptedReceived.
/**
* A contact has accepted our subscription request
*/
public void contactAcceptedReceived(SessionFriendAcceptedEvent event) {
final Set<String> groups = new HashSet<String>();
groups.add(event.getGroupName());
final YahooUser user = new YahooUser(event.getFrom());
// TODO clean up the next line. This implementation of constructor for YahooBuddy seems to be inappropriate here.
final YahooBuddy buddy = new YahooBuddy(getSession().getBuddyManager(), user, null, groups, null);
getSession().getBuddyManager().storeBuddy(buddy);
final Presence p = new Presence(Presence.Type.subscribed);
p.setTo(getSession().getJID());
p.setFrom(getSession().getTransport().convertIDToJID(event.getFrom()));
getSession().getTransport().sendPacket(p);
}
use of org.xmpp.packet.Presence in project Openfire by igniterealtime.
the class YahooListener method contactRejectionReceived.
/**
* @see org.openymsg.network.event.SessionAdapter#contactRequestReceived(org.openymsg.network.event.SessionEvent)
*/
/** is gone??
@Override
public void contactRequestReceived(SessionEvent event) {
final Presence p = new Presence(Presence.Type.subscribe);
p.setTo(getSession().getJID());
p.setFrom(getSession().getTransport().convertIDToJID(event.getFrom()));
getSession().getTransport().sendPacket(p);
}
*/
/**
* @see org.openymsg.network.event.SessionAdapter#contactRejectionReceived(org.openymsg.network.event.SessionFriendRejectedEvent)
*/
public void contactRejectionReceived(SessionFriendRejectedEvent event) {
// TODO: Is this correct? unsubscribed for a rejection?
Log.debug(event.toString());
Presence p = new Presence(Presence.Type.unsubscribed);
p.setTo(getSession().getJID());
p.setFrom(getSession().getTransport().convertIDToJID(event.getFrom()));
getSession().getTransport().sendPacket(p);
}
Aggregations