Packagecom.whirled.contrib.avrg.oneroom
Classpublic class OneRoomGameRoom

Room type superclass for games that take place in exactly one room. To use this class, games should create a subclass and set it as the roomType in the server agent. The subclass just needs to handle game logic in the given hooks, something like this:
 import com.whirled.contrib.avrg.oneroom.OneRoomGameRoom;
public class MyRoom extends OneRoomGameRoom { override public function finishInit () { super.finishInit(); // game initialization code }
override public function shutdown () { // game shutdown code super.shutdown(); }
override protected function messageReceived ( senderId :int, name :String, value :Object) :void { // game logic for when a message is received from a player, for example: if (name == MOVE) { _myState.applyChange(value as Move); _roomCtrl.props.set(GAMESTATE, _myState.toObject()); } }
override public function playerEntered (playerId :int) { // game logic for when a new player comes in the room }
override public function playerLeft (playerId :int) { // game logic for when a new player leaves the room } }

See also

OneRoomGameServer


Public Properties
 PropertyDefined by
  log : Log
The log associated with this room.
OneRoomGameRoom
Protected Properties
 PropertyDefined by
  _gameCtrl : AVRServerGameControl
The game control for the agent.
OneRoomGameRoom
  _roomCtrl : RoomSubControlServer
The room control for this room.
OneRoomGameRoom
  _server : OneRoomGameServer
The agent that spawned this room.
OneRoomGameRoom
Public Methods
 MethodDefined by
  
init(server:OneRoomGameServer, roomId:int):void
Intializes the game room.
OneRoomGameRoom
  
shutdown():void
Shuts down the game room.
OneRoomGameRoom
Protected Methods
 MethodDefined by
  
finishInit():void
Called once the room is initialized.
OneRoomGameRoom
  
messageReceived(senderId:int, name:String, value:Object):void
Called whan a game player in this room sends a message to the server agent.
OneRoomGameRoom
  
playerEntered(playerId:int):void
Called whan a game player enters the room.
OneRoomGameRoom
  
playerLeft(playerId:int):void
Called whan a game player leaves the room.
OneRoomGameRoom
Property detail
_gameCtrlproperty
protected var _gameCtrl:AVRServerGameControl

The game control for the agent.

logproperty 
public var log:Log

The log associated with this room. Includes a time stamp and a prefix with the id of the room.

_roomCtrlproperty 
protected var _roomCtrl:RoomSubControlServer

The room control for this room.

_serverproperty 
protected var _server:OneRoomGameServer

The agent that spawned this room.

Method detail
finishInit()method
protected function finishInit():void

Called once the room is initialized. Callers should override and set up game-specific state and objects etc., ensuring that super.finishInit is called first.

init()method 
public function init(server:OneRoomGameServer, roomId:int):void

Intializes the game room. Subclasses should not need to override this, but should initialize game specific members in finishInit.

Parameters
server:OneRoomGameServer
 
roomId:int

See also

messageReceived()method 
protected function messageReceived(senderId:int, name:String, value:Object):void

Called whan a game player in this room sends a message to the server agent. Subclasses should override and perform handling for game messages.

Parameters
senderId:int
 
name:String
 
value:Object
playerEntered()method 
protected function playerEntered(playerId:int):void

Called whan a game player enters the room. Subclasses should override and update their internal state for the addition of the player.

Parameters
playerId:int
playerLeft()method 
protected function playerLeft(playerId:int):void

Called whan a game player leaves the room. Subclasses should override and update their internal state for the removal of the player.

Parameters
playerId:int
shutdown()method 
public function shutdown():void

Shuts down the game room. Subclasses should override and remove listeners and clear state variables etc., ensuring that super.shutdown is called at the end.