Click or drag to resize

ModeratorMessageRequest Class

Sends a moderator message to a specific user or a group of users.
Inheritance Hierarchy
SystemObject
  BaseRequest
    GenericMessageRequest
      Sfs2X.RequestsModeratorMessageRequest

Namespace:  Sfs2X.Requests
Assembly:  SmartFox2X (in SmartFox2X.dll) Version: 1.8.0.0 (1.8.0)
Syntax
C#
public class ModeratorMessageRequest : GenericMessageRequest
Constructors
  NameDescription
Public methodModeratorMessageRequest(String, MessageRecipientMode)
See ModeratorMessageRequest(string, MessageRecipientMode, ISFSObject) constructor.
Public methodModeratorMessageRequest(String, MessageRecipientMode, ISFSObject)
Creates a new ModeratorMessageRequest instance.
Top
Remarks
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 MODERATOR_MESSAGE event.

Examples
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:
void SomeMethod() {
    sfs.AddEventListener(SFSEvent.MODERATOR_MESSAGE, OnModeratorMessage);

    // Set the message recipients: all users in the current Room
    MessageRecipientMode recipMode = new MessageRecipientMode(MessageRecipientMode.TO_ROOM, sfs.LastJoinedRoom);

    // Send the moderator message
    sfs.Send( new ModeratorMessageRequest("Hello everybody, I'm the Moderator!", recipMode) );
}

void OnModeratorMessage(BaseEvent evt) {
    Console.WriteLine("The moderator sent the following message: " + (string)evt.Params["message"]);                        // .Net / Unity
    System.Diagnostics.Debug.WriteLine("The moderator sent the following message: " + (string)evt.Params["message"]);       // UWP
}
See Also