Skip to content

Commit

Permalink
Merge pull request #1100 from guusdk/OF-1433_reflect-presence-updates
Browse files Browse the repository at this point in the history
OF-1433 / OF-454: Reflect presence updates
  • Loading branch information
akrherz committed Jun 29, 2018
2 parents e810a7d + ac11cba commit 91b1dd5
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
13 changes: 11 additions & 2 deletions src/java/org/jivesoftware/openfire/SessionManager.java
Expand Up @@ -654,14 +654,23 @@ private void broadcastPresenceOfOtherResource(LocalClientSession session) {
}
}

/**
* @deprecated Use {@link #broadcastPresenceToResources(JID, Presence)} instead.
*/
@Deprecated
public void broadcastPresenceToOtherResources(JID originatingResource, Presence presence)
{
broadcastPresenceToResources(originatingResource, presence);
}

/**
* Broadcasts presence updates from the originating user's resource to any of the user's
* existing available resources (if any).
* existing available resources (including the resource from where the update originates).
*
* @param originatingResource the full JID of the session that sent the presence update.
* @param presence the presence.
*/
public void broadcastPresenceToOtherResources(JID originatingResource, Presence presence) {
public void broadcastPresenceToResources( JID originatingResource, Presence presence) {
// RFC 6121 4.4.2 says we always send to the originating resource.
// Also RFC 6121 4.2.2 for updates.
presence.setTo(originatingResource);
Expand Down
Expand Up @@ -143,24 +143,28 @@ private void process(Presence presence, ClientSession session) throws Unauthoriz
Log.warn("Rejected available presence: " + presence + " - " + session);
return;
}
broadcastUpdate(presence.createCopy());

if (session != null) {
session.setPresence(presence);
if (!session.isInitialized()) {
initSession(session);
session.setInitialized(true);
}
}

broadcastUpdate(presence.createCopy());

if (session != null && !session.isInitialized()) {
initSession(session);
session.setInitialized(true);
}

// Notify the presence manager that the user is now available. The manager may
// remove the last presence status sent by the user when he went offline.
presenceManager.userAvailable(presence);
}
else if (Presence.Type.unavailable == type) {
broadcastUpdate(presence.createCopy());
broadcastUnavailableForDirectedPresences(presence);
if (session != null) {
session.setPresence(presence);
}
broadcastUpdate(presence.createCopy());
broadcastUnavailableForDirectedPresences(presence);
// Notify the presence manager that the user is now unavailable. The manager may
// save the last presence status sent by the user and keep track when the user
// went offline.
Expand Down
4 changes: 2 additions & 2 deletions src/java/org/jivesoftware/openfire/roster/Roster.java
Expand Up @@ -624,8 +624,8 @@ public void broadcastPresence(Presence packet) {
}
}
if (from != null) {
// Broadcast presence to other user's resources
SessionManager.getInstance().broadcastPresenceToOtherResources(from, packet);
// Broadcast presence to all resources of the user.
SessionManager.getInstance().broadcastPresenceToResources( from, packet);
}
}

Expand Down

0 comments on commit 91b1dd5

Please sign in to comment.