Click or drag to resize

AdminMessageRequest Class

Sends an administrator message to a specific user or a group of users.
Inheritance Hierarchy
SystemObject
  BaseRequest
    GenericMessageRequest
      Sfs2X.RequestsAdminMessageRequest

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

Examples
The following example sends an administration message to all the users in the Zone; it also shows how to handle the related event:
void SomeMethod() {
    sfs.AddEventListener(SFSEvent.ADMIN_MESSAGE, OnAdminMessage);

    // Set the message recipients: all users in the Zone
    MessageRecipientMode recipMode = new MessageRecipientMode(MessageRecipientMode.TO_ZONE, null);

    // Send the administrator message
    sfs.Send( new AdminMessageRequest("Hello to everybody from the Administrator!", recipMode) );
}

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