Packagecom.electrotank.electroserver4.message.request
Classpublic class PublicMessageRequest
InheritancePublicMessageRequest Inheritance com.electrotank.electroserver4.message.request.RequestImpl

This class is used to send a public message to a room. A public message can contain a message and an optional EsObject. To send a public message to a room you must specify the room id and zone id.
Public messages can be captured by plugin event handlers and modified or stopped. If the room has language filters enabled then the message will be applied to the filter.


Example
This shows how to send a simple public message to a room with no EsObject attached.
    
        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;
         private var roomId:Number;
         private var zoneId:Number;
         
         function init():void {
             es.addEventListener(MessageType.PublicMessageEvent, "onPublicMessageEvent", this);
         }
        function sendPublicMessage(msg:String):void {
            //Create the PublicMessageRequest object and populate it
            var pmr:PublicMessageRequest = new PublicMessageRequest();
            pmr.setMessage(msg);
            pmr.setRoomId(roomId);
            pmr.setZoneId(zoneId);
            //Send the request
            es.send(pmr);
        }
        function onPublicMessageEvent(e:PublicMessageEvent):void {
            var from:String = e.getUserName();
            var msg:String = e.getMessage();
            trace(from+": "+msg);
        }
        init();
        sendPublicMessage("Hello world");
         
This shows how to send a public message to a room with an EsObject attached.
        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;
         private var roomId:Number;
         private var zoneId:Number;
         
         function init():void {
             es.addEventListener(MessageType.PublicMessageEvent, "onPublicMessageEvent", this);
         }
        function sendPublicMessage(msg:String):void {
            //Create an EsObject that contains custom information to send to the room
            var esob:EsObject = new EsObject();
            esob.setString("SoundFx", "Boom.mp3");
            esob.setInteger("Loops", 4);
            //Create the PublicMessageRequest object and populate it
            var pmr:PublicMessageRequest = new PublicMessageRequest();
            pmr.setMessage(msg);
            pmr.setRoomId(roomId);
            pmr.setZoneId(zoneId);
            pmr.setEsObject(esob);
            //Send the request
            es.send(pmr);
        }
        function onPublicMessageEvent(e:PublicMessageEvent):void {
            var from:String = e.getUserName();
            var msg:String = e.getMessage();
            //Get the EsObject
            var esob:EsObject = e.getEsObject();
            trace("SoundFx: "+esob.getString("SoundFx"));
            trace("Loops: "+esob.getInteger("Loops"));
            trace(from+": "+msg);
        }
        init();
        sendPublicMessage("Hello world");
        



Public Methods
 MethodDefined by
  
Creates a new instance of the PublicMessageRequest class.
PublicMessageRequest
  
Gets the optional EsObjec to be sent with the message.
PublicMessageRequest
  
getMessage():String
Returns the message text to be sent to the room.
PublicMessageRequest
  
getRoomId():Number
Returns the room id of the room to which the message is being sent.
PublicMessageRequest
  
getZoneId():Number
Returns the zone id of the room to which the message is being sent.
PublicMessageRequest
  
Sets the optional EsObject to be sent along with chat message to the room.
PublicMessageRequest
  
setMessage(message:String):void
The message text to be sent to the room.
PublicMessageRequest
  
setRoomId(rId:Number):void
The room id of the room to which the message is being sent.
PublicMessageRequest
  
setZoneId(zId:Number):void
The id of the zone that holds the room to which the message is being sent.
PublicMessageRequest
  
PublicMessageRequest
Constructor detail
PublicMessageRequest()constructor
public function PublicMessageRequest()

Creates a new instance of the PublicMessageRequest class.

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

Gets the optional EsObjec to be sent with the message.

Returns
EsObject — Returns the option EsObjec to be sent with the message.
getMessage()method 
public function getMessage():String

Returns the message text to be sent to the room.

Returns
String — Returns the message text to be sent to the room.
getRoomId()method 
public function getRoomId():Number

Returns the room id of the room to which the message is being sent.

Returns
Number — Returns the room id of the room to which the message is being sent.
getZoneId()method 
public function getZoneId():Number

Returns the zone id of the room to which the message is being sent.

Returns
Number — Returns the zone id of the room to which the message is being sent.
setEsObject()method 
public function setEsObject(eob:EsObject):void

Sets the optional EsObject to be sent along with chat message to the room.

Parameters
eob:EsObject — The optional EsObject to be attached to the message.
setMessage()method 
public function setMessage(message:String):void

The message text to be sent to the room.

Parameters
message:String — The message text to be sent to the room.
setRoomId()method 
public function setRoomId(rId:Number):void

The room id of the room to which the message is being sent.

Parameters
rId:Number — The room id of the room to which the message is being sent.
setZoneId()method 
public function setZoneId(zId:Number):void

The id of the zone that holds the room to which the message is being sent.

Parameters
zId:Number — The id of the zone that holds the room to which the message is being sent.
validate()method 
public override function validate():ValidationResponse

Returns
ValidationResponse