| Package | com.whirled.contrib.avrg.oneroom |
| Class | public class OneRoomGameRoom |
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
| Property | Defined by | ||
|---|---|---|---|
| log : Log The log associated with this room.
| OneRoomGameRoom | ||
| Property | Defined 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 | ||
| Method | Defined by | ||
|---|---|---|---|
|
init(server:OneRoomGameServer, roomId:int):void
Intializes the game room.
| OneRoomGameRoom | ||
|
shutdown():void
Shuts down the game room.
| OneRoomGameRoom | ||
| Method | Defined 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 | ||
| _gameCtrl | property |
protected var _gameCtrl:AVRServerGameControlThe game control for the agent.
| log | property |
public var log:LogThe log associated with this room. Includes a time stamp and a prefix with the id of the room.
| _roomCtrl | property |
protected var _roomCtrl:RoomSubControlServerThe room control for this room.
| _server | property |
protected var _server:OneRoomGameServerThe agent that spawned this room.
| 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.
server:OneRoomGameServer |
|
roomId:int |
See also
| messageReceived | () | method |
protected function messageReceived(senderId:int, name:String, value:Object):voidCalled whan a game player in this room sends a message to the server agent. Subclasses should override and perform handling for game messages.
ParameterssenderId:int |
|
name:String |
|
value:Object |
| playerEntered | () | method |
protected function playerEntered(playerId:int):voidCalled whan a game player enters the room. Subclasses should override and update their internal state for the addition of the player.
ParametersplayerId:int |
| playerLeft | () | method |
protected function playerLeft(playerId:int):voidCalled whan a game player leaves the room. Subclasses should override and update their internal state for the removal of the player.
ParametersplayerId: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.