Packagecom.electrotank.electroserver4.message.request
Classpublic class PrivateMessageRequest
InheritancePrivateMessageRequest Inheritance com.electrotank.electroserver4.message.request.RequestImpl

This request is used to send private messages to one or more users at once. A private message can contain an optional EsObject. A private message can be sent from any user to any other user. Rooms play no part in this.
Private messages can be intercepted by a Private Message Event Handler on the server and modified or killed. Private message filtering can be enabled using the web-based administrator.


Example
This shows how to send a private message to one user. It also shows how to capture the PrivateMessageEvent.
    import com.electrotank.electroserver4.ElectroServer;
    import com.electrotank.electroserver4.message.MessageType;
    import com.electrotank.electroserver4.message.request.
    import com.electrotank.electroserver4.message.response.
    import com.electrotank.electroserver4.message.event.
    
    private var es:ElectroServer;
    function init():void {
        es.addEventListener(MessageType.PrivateMessageEvent, "onPrivateMessageEvent", this);
    }
    function sendPrivateMessage(message:String, userName:String):void {
        //build the request
        var pmr:PrivateMessageRequest = new PrivateMessageRequest();
        pmr.setMessage(message);
        pmr.setUserNames([userName]);
        //send it
        es.send(pmr);
    }
    function onPrivateMessageEvent(e:PrivateMessageEvent):void {
        var from:String = e.getUserName();
        var message:String = e.getMessage();
        trace(from+": "+message);
    }
    init();
    sendPrivateMessage("Hello world", ["fluffy323"]);
        



Public Methods
 MethodDefined by
  
Creates a new instance of the PrivateMessageRequest class.
PrivateMessageRequest
  
Returns the optional EsObject.
PrivateMessageRequest
  
getMessage():String
Returns the message text to be sent.
PrivateMessageRequest
  
getUserNames():Array
Returns the list of user names to whom this message will be sent.
PrivateMessageRequest
  
getUsers():Array
Returns the list of users to whom this message will be sent.
PrivateMessageRequest
  
Sets the optional EsObject that will be sent along with this message.
PrivateMessageRequest
  
setMessage(message:String):void
Sets the message text to be sent.
PrivateMessageRequest
  
setUserNames(names:Array):void
An array of user names of the users to whom the message will be sent.
PrivateMessageRequest
  
setUsers(users:Array):void
Sets the list of users to whom this message will be sent.
PrivateMessageRequest
  
PrivateMessageRequest
Constructor detail
PrivateMessageRequest()constructor
public function PrivateMessageRequest()

Creates a new instance of the PrivateMessageRequest class.

Method detail
getEsObject()method
public function getEsObject():EsObject

Returns the optional EsObject.

Returns
EsObject — Returns the optional EsObject.
getMessage()method 
public function getMessage():String

Returns the message text to be sent.

Returns
String — Returns the message text to be sent.
getUserNames()method 
public function getUserNames():Array

Returns the list of user names to whom this message will be sent.

Returns
Array — Returns the list of user names to whom this message will be sent.
getUsers()method 
public function getUsers():Array

Returns the list of users to whom this message will be sent.

Returns
Array — Returns the list of users to whom this message will be sent.
setEsObject()method 
public function setEsObject(eob:EsObject):void

Sets the optional EsObject that will be sent along with this message.

Parameters
eob:EsObject — The optional EsObject that will be sent along with this message.
setMessage()method 
public function setMessage(message:String):void

Sets the message text to be sent.

Parameters
message:String — The message text to be sent.
setUserNames()method 
public function setUserNames(names:Array):void

An array of user names of the users to whom the message will be sent.

Parameters
names:Array — An array of user names of the users to whom the message will be sent.
setUsers()method 
public function setUsers(users:Array):void

Sets the list of users to whom this message will be sent.

Parameters
users:Array — The list of users to whom this message will be sent.
validate()method 
public override function validate():ValidationResponse

Returns
ValidationResponse