Class SFS2X.Requests.System.ModeratorMessageRequest

Sends a moderator message to a specific user or to a group of users.

Class Summary
Constructor Attributes Constructor Name and Description
 
SFS2X.Requests.System.ModeratorMessageRequest(message, recipientMode, params)
Creates a new ModeratorMessageRequest instance.

Class Detail

SFS2X.Requests.System.ModeratorMessageRequest(message, recipientMode, params)
Creates a new ModeratorMessageRequest instance. The instance must be passed to the SmartFox.send() method for the request to be performed.

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 User.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.

The following 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.Requests.MessageRecipientMode(SFS2X.Requests.MessageRecipientMode.TO_ROOM, sfs.lastJoinedRoom);
	
	// Send the moderator message
	sfs.send(new SFS2X.Requests.System.ModeratorMessageRequest("Hello everybody, I'm the Moderator!", recipMode));
}

function onModeratorMessage(evtParams)
{
	console.log("The moderator sent the following message: " + evtParams.message);
}
Parameters:
{String} message
The message of the moderator to be sent to the target user/s defined by the recipientMode parameter.
{MessageRecipientMode} recipientMode
An instance of MessageRecipientMode containing the target to which the message should be delivered.
{Object} params Optional, Default: null
An object containing custom parameters to be sent to the recipient user/s.
See also:
SFS2X.SmartFox#send
SFS2X.SFSEvent.MODERATOR_MESSAGE
SFS2X.Requests.MessageRecipientMode
SFS2X.Entities.SFSUser#privilegeId
SFS2X.Requests.System.AdminMessageRequest