use of org.jivesoftware.openfire.muc.cluster.BroadcastPresenceRequest in project Openfire by igniterealtime.
the class LocalMUCRoom method broadcastPresence.
/**
* Broadcasts the specified presence to all room occupants. If the presence belongs to a
* user whose role cannot be broadcast then the presence will only be sent to the presence's
* user. On the other hand, the JID of the user that sent the presence won't be included if the
* room is semi-anon and the target occupant is not a moderator.
*
* @param presence the presence to broadcast.
* @param isJoinPresence If the presence is sent in the context of joining the room.
*/
private void broadcastPresence(Presence presence, boolean isJoinPresence) {
if (presence == null) {
return;
}
if (!shouldBroadcastPresence(presence)) {
// Just send the presence to the sender of the presence
try {
for (MUCRole occupant : getOccupantsByNickname(presence.getFrom().getResource())) {
occupant.send(presence);
}
} catch (UserNotFoundException e) {
// Do nothing
}
return;
}
// Broadcast presence to occupants hosted by other cluster nodes
BroadcastPresenceRequest request = new BroadcastPresenceRequest(this, presence, isJoinPresence);
CacheFactory.doClusterTask(request);
// Broadcast presence to occupants connected to this JVM
request = new BroadcastPresenceRequest(this, presence, isJoinPresence);
request.setOriginator(true);
request.run();
}
Aggregations