com.electrotank.electroserver5.client.api
Class EsJoinZoneEvent

java.lang.Object
  extended by com.electrotank.electroserver5.client.events.Event<EsMessageType>
      extended by com.electrotank.electroserver5.client.api.helper.EsMessage
          extended by com.electrotank.electroserver5.client.api.helper.EsEvent
              extended by com.electrotank.electroserver5.client.api.EsJoinZoneEvent
All Implemented Interfaces:
ThriftSerializable

public class EsJoinZoneEvent
extends EsEvent

A zone is a collection of rooms. A room can only exist in a single zone. When a user joins a room the user also joins that zone, if the user was not already in that zone. When a user joins a zone this event occurs. After joining the zone, ZoneManager can be used to get a list of all rooms in the zone, and number of users in each room. Shows the most simple example of how to join a room and capture the JoinZoneEvent.

package  {
        import com.electrotank.electroserver5.api.CreateRoomRequest;
        import com.electrotank.electroserver5.api.JoinRoomEvent;
        import com.electrotank.electroserver5.api.JoinZoneEvent;
        import com.electrotank.electroserver5.api.MessageType;
        import com.electrotank.electroserver5.ElectroServer;
        import com.electrotank.electroserver5.user.User;
        import com.electrotank.electroserver5.zone.Room;
        import com.electrotank.electroserver5.zone.Zone;
        import flash.events.Event;

        public class RoomJoiner {

                private var _es:ElectroServer;

                public function initialize():void {
                        //listen for the JoinRoomEvent so we know when it happens
                        _es.engine.addEventListener(MessageType.JoinRoomEvent.name, onJoinRoomEvent);
                        _es.engine.addEventListener(MessageType.JoinZoneEvent.name, onJoinZoneEvent);

                        //create the request and populate it with the room details
                        var crr:CreateRoomRequest = new CreateRoomRequest();
                        crr.roomName = "MyRoom";
                        crr.zoneName = "MyZone";

                        //send it
                        _es.engine.send(crr);
                }

                private function onJoinRoomEvent(e:JoinRoomEvent):void {
                        trace("room joined!");

                        //get the room you're in
                        var room:Room = _es.managerHelper.zoneManager.zoneById(e.zoneId).roomById(e.roomId);

                        //print out the users in the room
                        for each (var user:User in room.users) {
                                trace(user.userName);
                        }
                }

                private function onJoinZoneEvent(e:JoinZoneEvent):void {
                        var zone:Zone = _es.managerHelper.zoneManager.zoneById(e.zoneId);

                        trace("zone joined! name: "+zone.name);

                        //print out the rooms in the zone
                        for each (var room:Room in zone.rooms) {
                                trace(room.name);
                        }
                }

                public function set es(value:ElectroServer):void {
                        _es = value;
                }

        }

}
    


Constructor Summary
EsJoinZoneEvent()
           
EsJoinZoneEvent(org.apache.thrift.TBase t)
           
 
Method Summary
 void fromThrift(org.apache.thrift.TBase t_)
           
 List<EsRoomListEntry> getRooms()
          List of all the rooms in this zone, containing their public properties (name, capacity, hasPassword, description)
 int getZoneId()
          The id of the zone just joined.
 String getZoneName()
          The name of the zone just joined.
 com.electrotank.electroserver5.thrift.ThriftJoinZoneEvent newThrift()
           
 void setRooms(List<EsRoomListEntry> v)
          List of all the rooms in this zone, containing their public properties (name, capacity, hasPassword, description)
 void setZoneId(int v)
          The id of the zone just joined.
 void setZoneName(String v)
          The name of the zone just joined.
 com.electrotank.electroserver5.thrift.ThriftJoinZoneEvent toThrift()
           
 
Methods inherited from class com.electrotank.electroserver5.client.api.helper.EsMessage
getMessageNumber, getMessageType, getRequestId, getServerId, setMessageNumber, setMessageType, setRequestId, setServerId
 
Methods inherited from class com.electrotank.electroserver5.client.events.Event
getType, setType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EsJoinZoneEvent

public EsJoinZoneEvent()

EsJoinZoneEvent

public EsJoinZoneEvent(org.apache.thrift.TBase t)
Method Detail

toThrift

public com.electrotank.electroserver5.thrift.ThriftJoinZoneEvent toThrift()

newThrift

public com.electrotank.electroserver5.thrift.ThriftJoinZoneEvent newThrift()

fromThrift

public void fromThrift(org.apache.thrift.TBase t_)

getZoneId

public int getZoneId()
The id of the zone just joined.


setZoneId

public void setZoneId(int v)
The id of the zone just joined.


getZoneName

public String getZoneName()
The name of the zone just joined.


setZoneName

public void setZoneName(String v)
The name of the zone just joined.


getRooms

public List<EsRoomListEntry> getRooms()
List of all the rooms in this zone, containing their public properties (name, capacity, hasPassword, description)


setRooms

public void setRooms(List<EsRoomListEntry> v)
List of all the rooms in this zone, containing their public properties (name, capacity, hasPassword, description)



Copyright © 2007-2010 Electrotank, Inc. All Rights Reserved.