ModeratorMessageRequest
Sends a moderator message to a specific user or to a group of users.
new ModeratorMessageRequest(message, recipientMode[, params])
Creates a new ModeratorMessageRequest instance. The instance must be passed to the SmartFox.send() method for the request to be executed.
This request sends a moderator message to a specific user or to a group of users. The current user must have moderation 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 moderatorMessage event.
Example
This example sends a moderator message to all the users in the last joned Room; it also shows how to handle the related event.
function someMethod()
{
sfs.addEventListener(SFS2X.SFSEvent.MODERATOR_MESSAGE, onModeratorMessage, this);
// Set the message recipients: all users in the current Room
var recipMode = new SFS2X.MessageRecipientMode(SFS2X.MessageRecipientMode.TO_ROOM, sfs.lastJoinedRoom);
// Send the moderator message
sfs.send(new SFS2X.ModeratorMessageRequest("Hello everybody, I'm the Moderator!", recipMode));
}
function onModeratorMessage(evtParams)
{
console.log("The moderator sent the following message: " + evtParams.message);
}
Parameters
Name | Type | Optional | Description |
---|---|---|---|
message |
|
|
The message of the moderator 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 |
A SFSObject containing custom parameters to be sent to the recipient user/s. Defaults to |