ElectroServer 5 Client: Cocoa-Touch
EsPublicMessageEvent Class Reference

This event occurs when a public message is sent to a room to which the client belongs. More...

Inheritance diagram for EsPublicMessageEvent:
EsEvent EsMessage EsEventDispatcherEvent

Instance Methods

(id) - init
 
(id) - initWithThriftObject:
 
(void) - fromThrift:
 
(ThriftPublicMessageEvent *) - toThrift
 
(id) - newThrift
 

Properties

NSString * message
 The chat message. More...
 
NSString * userName
 The name of the user that sent the message. More...
 
int32_t zoneId
 The id of the zone that contains the room. More...
 
int32_t roomId
 The id of the room that received the message. More...
 
EsObjectesObject
 Optional EsObject property. More...
 

Additional Inherited Members

- Protected Attributes inherited from EsMessage
int messageType_
 

Detailed Description

This event occurs when a public message is sent to a room to which the client belongs.

The event contains the name of the user that sent it, the message, room and zone id, and an optional EsObject.

This shows how to send a simple public message and capture the event.

private var _es:ElectroServer;
private var _room:Room;
private function initialize():void {
        _es.engine.addEventListener(MessageType.PublicMessageEvent.name, onPublicMessageEvent);
}
private function sendTestMessage():void {
        //create the message object
        var pmr:PublicMessageRequest = new PublicMessageRequest();
        //configure it
        pmr.message = "Hello World!";
        pmr.roomId = _room.id;
        pmr.zoneId = _room.zoneId;
        //send it
        _es.engine.send(pmr);
}
             This shows how to send a public message to a room with an EsObject attached, and capture the event.
private var _es:ElectroServer;
private var _room:Room;
private function initialize():void {
        _es.engine.addEventListener(MessageType.PublicMessageEvent.name, onPublicMessageEvent);
}
private function sendTestMessage():void {
        //create the message object
        var pmr:PublicMessageRequest = new PublicMessageRequest();
        //configure it
        pmr.message = "Hello World!";
        pmr.roomId = _room.id;
        pmr.zoneId = _room.zoneId;
        //create an EsObject to send
        var esob:EsObject = new EsObject();
        esob.setBoolean("playAudioWithMessage", true);
        //put it on the message
        pmr.esObject = esob;
        //send it
        _es.engine.send(pmr);
}
private function onPublicMessageEvent(e:PublicMessageEvent):void {
        trace(e.userName + " says '" + e.message + "'");
        trace("playAudioWithMessage: " + e.esObject.getBoolean("playAudioWithMessage").toString());
}

Method Documentation

- (void) fromThrift: (id)  thriftObject

Reimplemented from EsMessage.

- (id) init
- (id) initWithThriftObject: (id)  thriftObject
- (id) newThrift

Reimplemented from EsMessage.

- (ThriftPublicMessageEvent *) toThrift

Reimplemented from EsMessage.

Property Documentation

- (EsObject*) esObject
readwritenonatomicretain

Optional EsObject property.

- (NSString*) message
readwritenonatomicretain

The chat message.

- (int32_t) roomId
readwritenonatomicassign

The id of the room that received the message.

- (NSString*) userName
readwritenonatomicretain

The name of the user that sent the message.

- (int32_t) zoneId
readwritenonatomicassign

The id of the zone that contains the room.