| Package | com.electrotank.electroserver4.message.request |
| Class | public class PublicMessageRequest |
| Inheritance | PublicMessageRequest com.electrotank.electroserver4.message.request.RequestImpl |
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");
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");
| Method | Defined 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 | ||
|
setEsObject(eob:EsObject):void
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 | |||
| PublicMessageRequest | () | constructor |
public function PublicMessageRequest()Creates a new instance of the PublicMessageRequest class.
| getEsObject | () | method |
public function getEsObject():EsObjectGets the optional EsObjec to be sent with the message.
ReturnsEsObject —
Returns the option EsObjec to be sent with the message.
|
| getMessage | () | method |
public function getMessage():StringReturns the message text to be sent to the room.
ReturnsString — Returns the message text to be sent to the room.
|
| getRoomId | () | method |
public function getRoomId():NumberReturns the room id of the room to which the message is being sent.
ReturnsNumber — Returns the room id of the room to which the message is being sent.
|
| getZoneId | () | method |
public function getZoneId():NumberReturns the zone id of the room to which the message is being sent.
ReturnsNumber — Returns the zone id of the room to which the message is being sent.
|
| setEsObject | () | method |
public function setEsObject(eob:EsObject):voidSets the optional EsObject to be sent along with chat message to the room.
Parameterseob:EsObject — The optional EsObject to be attached to the message.
|
| setMessage | () | method |
public function setMessage(message:String):voidThe message text to be sent to the room.
Parametersmessage:String — The message text to be sent to the room.
|
| setRoomId | () | method |
public function setRoomId(rId:Number):voidThe room id of the room to which the message is being sent.
ParametersrId:Number — The room id of the room to which the message is being sent.
|
| setZoneId | () | method |
public function setZoneId(zId:Number):voidThe id of the zone that holds the room to which the message is being sent.
ParameterszId:Number — The id of the zone that holds the room to which the message is being sent.
|
| validate | () | method |