AdminMessageRequest
Sends an administrator message to a specific user or to a group of users.
new AdminMessageRequest(message, recipientMode[, params])
Creates a new AdminMessageRequest instance. The instance must be passed to the SmartFox.send() method for the request to be executed.
This request sends an administrator message to a specific user or to a group of users. The current user must have administration privileges to be able to send the message (see the SFSUser.privilegeId property).
The recipientMode parameter in the class constructor is used to determine the message recipients: a single user or all the users in a Room, a Group or the entire Zone. Upon message delivery, the clients of the recipient users dispatch the adminMessage event.
Example
This example sends an administration message to all the users in the Zone; it also shows how to handle the related event.
function someMethod()
{
sfs.addEventListener(SFS2X.SFSEvent.ADMIN_MESSAGE, onAdminMessage, this);
// Set the message recipients: all users in the Zone
var recipMode = new SFS2X.MessageRecipientMode(SFS2X.MessageRecipientMode.TO_ZONE, null);
// Send the administrator message
sfs.send(new SFS2X.AdminMessageRequest("Hello to everybody from the Administrator!", recipMode));
}
function onAdminMessage(evtParams)
{
console.log("The administrator sent the following message: " + evtParams.message);
}
Parameters
Name | Type | Optional | Description |
---|---|---|---|
message |
|
|
The message of the administrator to be sent to the target user/s defined by the recipientMode parameter. |
recipientMode |
|
|
An instance of MessageRecipientMode containing the target to which the message should be delivered. |
params |
|
Yes |
An SFSObject containing custom parameters to be sent to the recipient user/s. Defaults to |