Packagecom.electrotank.electroserver4.message.request
Classpublic class LeaveRoomRequest
InheritanceLeaveRoomRequest Inheritance com.electrotank.electroserver4.message.request.RequestImpl

This request allows you to leave a room. In ElectroServer 4 you can exist in multiple rooms at once, or no rooms. When you join a new room you need to request to leave the previous room if you no longer want to be in that room. Just build the request, give it the room and zone ids, and send it. When you've been removed from a room you'll receive a RoomLeftEvent. If you have also left the zone then you'll receive a ZoneLeftEvent. You can be moved into our out of rooms by server-side plugins or the Game Manager as well.


Example
This example shows how to leave a room.
    import com.electrotank.electroserver4.ElectroServer;
    import com.electrotank.electroserver4.message.event.LeaveRoomEvent;
    import com.electrotank.electroserver4.message.MessageType;
    import com.electrotank.electroserver4.message.request.LeaveRoomRequest;
    import com.electrotank.electroserver4.room.Room;
    
    //
    var es:ElectroServer;//assume this is created elsewhere and a connection and login occurred.
    var myRoom:Room;//some room you are in
    function init():void {
        es.addEventListener(MessageType.LeaveRoomEvent, "onLeaveRoomEvent", this);
    }
    function leaveRoom():void {
        var lrr:LeaveRoomRequest = new LeaveRoomRequest();
        lrr.setRoomId(myRoom.getRoomId());
        es.send(lrr);
    }
    function onLeaveRoomEvent(e:LeaveRoomEvent):void {
        trace("Left room: "+e.getRoomId());
    }
    init();
    leaveRoom();
        



Public Methods
 MethodDefined by
  
Creates a new instance of the LeaveRoomRequest class.
LeaveRoomRequest
  
getRoomId():Number
Returns the id of the room you want to leave.
LeaveRoomRequest
  
getZoneId():Number
Returns the id of the zone you want to leave.
LeaveRoomRequest
  
setRoomId(rId:Number):void
Sets the id of the room that you want to leave.
LeaveRoomRequest
  
setZoneId(zId:Number):void
Sets the id of the zone you want to leave.
LeaveRoomRequest
  
LeaveRoomRequest
Constructor detail
LeaveRoomRequest()constructor
public function LeaveRoomRequest()

Creates a new instance of the LeaveRoomRequest class.

Method detail
getRoomId()method
public function getRoomId():Number

Returns the id of the room you want to leave.

Returns
Number — The id of the room you want to leave.
getZoneId()method 
public function getZoneId():Number

Returns the id of the zone you want to leave.

Returns
Number — The id of the zone you want to leave.
setRoomId()method 
public function setRoomId(rId:Number):void

Sets the id of the room that you want to leave.

Parameters
rId:Number — The id of the room you want to leave.
setZoneId()method 
public function setZoneId(zId:Number):void

Sets the id of the zone you want to leave.

Parameters
zId:Number — The id of the zone you want to leave.
validate()method 
public override function validate():ValidationResponse

Returns
ValidationResponse