Package | com.smartfoxserver.v2.requests |
Class | public class PrivateMessageRequest |
Inheritance | PrivateMessageRequest com.smartfoxserver.v2.requests.GenericMessageRequest |
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 privateMessage 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.
See also
Method | Defined By | ||
---|---|---|---|
PrivateMessageRequest(message:String, recipientId:int, params:ISFSObject = null)
Creates a new PrivateMessageRequest instance. | PrivateMessageRequest |
PrivateMessageRequest | () | Constructor |
public function PrivateMessageRequest(message:String, recipientId:int, params:ISFSObject = null)
Creates a new PrivateMessageRequest instance. The instance must be passed to the SmartFox.send() method for the request to be performed.
Parametersmessage:String — The message to be sent to to the recipient user.
| |
recipientId:int — The id of the user to which the message is to be sent.
| |
params:ISFSObject (default = null ) — An instance of SFSObject containing additional custom parameters to be sent to the message recipient (for example the color of the text, etc).
|
See also
private function someMethod():void { sfs.addEventListener(SFSEvent.PRIVATE_MESSAGE, onPrivateMessage); // Send a private message to Jack var user:User = sfs.usermanager.getUserByName("Jack"); sfs.send(new PrivateMessageRequest("Hello Jack!", user.id)); } private function onPrivateMessage(evt:SFSEvent):void { // As messages are forwarded to the sender too, // I have to check if I am the sender var sender:User = evt.params.sender; if (sender != sfs.mySelf) trace("User " + sender.name + " sent me this PM:", evt.params.message); }