Commit 69ecb34f authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gaston

Modified #sendServerMessage so that it only sends messages to active user...

Modified #sendServerMessage so that it only sends messages to active user sessions. Also an explanation was added to the methods comments.


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@1285 b35dd754-fafc-0310-a699-88a17e54d16e
parent ba665e8d
...@@ -1083,10 +1083,28 @@ public class SessionManager extends BasicModule { ...@@ -1083,10 +1083,28 @@ public class SessionManager extends BasicModule {
} }
/**
* Sends a message with a given subject and body to all the active user sessions in the server.
*
* @param subject the subject to broadcast.
* @param body the body to broadcast.
*/
public void sendServerMessage(String subject, String body) { public void sendServerMessage(String subject, String body) {
sendServerMessage(null, subject, body); sendServerMessage(null, subject, body);
} }
/**
* Sends a message with a given subject and body to one or more user sessions related to the
* specified address. If address is null or the address's node is null then the message will be
* sent to all the user sessions. But if the address includes a node but no resource then
* the message will be sent to all the user sessions of the requeted user (defined by the node).
* Finally, if the address is a full JID then the message will be sent to the session associated
* to the full JID. If no session is found then the message is not sent.
*
* @param address the address that defines the sessions that will receive the message.
* @param subject the subject to broadcast.
* @param body the body to broadcast.
*/
public void sendServerMessage(JID address, String subject, String body) { public void sendServerMessage(JID address, String subject, String body) {
Message packet = createServerMessage(subject, body); Message packet = createServerMessage(subject, body);
try { try {
...@@ -1097,7 +1115,10 @@ public class SessionManager extends BasicModule { ...@@ -1097,7 +1115,10 @@ public class SessionManager extends BasicModule {
userBroadcast(address.getNode(), packet); userBroadcast(address.getNode(), packet);
} }
else { else {
router.route(packet); ClientSession session = getSession(address);
if (session != null) {
session.process(packet);
}
} }
} }
catch (UnauthorizedException e) { catch (UnauthorizedException e) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment