Class SFS2X.Requests.System.AdminMessageRequest

Sends an administrator message to a specific user or to a group of users.

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

Class Detail

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

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 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 adminMessage event.

The following 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.Requests.MessageRecipientMode(SFS2X.Requests.MessageRecipientMode.TO_ZONE, null);
	
	// Send the administrator message
	sfs.send(new SFS2X.Requests.System.AdminMessageRequest("Hello to everybody from the Administrator!", recipMode));
}

function onAdminMessage(evtParams)
{
	console.log("The administrator sent the following message: " + evtParams.message);
}
Parameters:
{String} message
The message of the administrator 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.ADMIN_MESSAGE
SFS2X.Requests.MessageRecipientMode
SFS2X.Entities.SFSUser#privilegeId
SFS2X.Requests.System.ModeratorMessageRequest