Sends a private chat message.

Namespace: Sfs2X.Requests
Assembly: SmartFox2X (in SmartFox2X.dll) Version: 1.7.0.0 (1.7.0)

Syntax

C#
public class PrivateMessageRequest : GenericMessageRequest

Remarks

The private message is dispatched to a specific user, who can be in any server Room, or even in no Room at all. The message is delivered by means of the PRIVATE_MESSAGE event. It is also returned to the sender: this allows showing the messages in the correct order in the application interface. It is also possible to send an optional object together with the message: it can contain custom parameters useful to transmit, for example, additional informations related to the message, like the text font or color, or other formatting details.

Examples

The following example sends a private message and handles the respective event:
 Copy imageCopy
void SomeMethod() {
    sfs.AddEventListener(SFSEvent.PRIVATE_MESSAGE, OnPrivateMessage);
    // Send a private message to Jack
    User messageRecipient = sfs.UserManager.GetUserByName("Jack");
    sfs.Send( new PrivateMessageRequest("Hello Jack!", messageRecipient.Id) );
}
void OnPrivateMessage(BaseEvent evt) {
    // As messages are forwarded to the sender too, I have to check if I am the sender
    User sender = (User)evt.Params["sender"];
    if (sender != sfs.MySelf)
    {
        Console.WriteLine("User " + sender.Name + " sent me this PM: " + (string)evt.Params["message"]);                        // .Net / Unity
        System.Diagnostics.Debug.WriteLine("User " + sender.Name + " sent me this PM: " + (string)evt.Params["message"]);       // Windows Universal
}
}

Inheritance Hierarchy

System..::..Object
  BaseRequest
    GenericMessageRequest
      Sfs2X.Requests..::..PrivateMessageRequest

See Also