Packagecom.whirled.avrg
Classpublic class AVRServerGameControl
InheritanceAVRServerGameControl Inheritance AbstractControl Inheritance flash.events.EventDispatcher

This file should be included by the server agents of AVR games so that they can communicate with the whirled. Server agents are normally responsible for deciding how players will be grouped and for an arbitrary amount of the game logic.

AVRGame means: Alternate Virtual Reality Game, and refers to games played within the whirled environment with your avatar.

AVR games can be significantly more complicated than lobbied games. Please consult the whirled wiki section on AVRGs as well as the AVRG discussion forum if you're having any problems.

See also

http://wiki.whirled.com/AVR_Games
http://www.whirled.com/#whirleds-d_135


Public Properties
 PropertyDefined by
  game : GameSubControlServer
[read-only] Accesses the server agent's game sub control.
AVRServerGameControl
  props : PropertySubControl
[read-only] Accesses the private properties for the server agent: these are not distributed to any clients and can thus be updated with greater frequency than the game-global ones.
AVRServerGameControl
Public Methods
 MethodDefined by
  
Creates a new game control for a server agent.
AVRServerGameControl
 Inherited
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
Registers an event listener.
AbstractControl
 Inherited
doBatch(fn:Function, ... args):void
Execute the specified function as a batch of commands that will be sent to the server together.
AbstractControl
  
Accesses the server agent's player sub control for a player with a given id.
AVRServerGameControl
  
Accesses the server agent's room sub control for a given room id.
AVRServerGameControl
 Inherited
isConnected():Boolean
Are we connected and running inside the whirled environment, or has someone just loaded up our SWF by itself?
AbstractControl
  
loadOfflinePlayer(playerId:int, success:Function, failure:Function):void
Loads the property space of an offline player and calls your function with it as an argument.
AVRServerGameControl
 Inherited
removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
Unregisters an event listener.
AbstractControl
Events
 EventSummaryDefined by
 Inherited Event.UNLOAD Dispatched when the SWF using this control has been unloaded.AbstractControl
Property detail
gameproperty
game:GameSubControlServer  [read-only]

Accesses the server agent's game sub control.

Implementation
    public function get game():GameSubControlServer
propsproperty 
props:PropertySubControl  [read-only]

Accesses the private properties for the server agent: these are not distributed to any clients and can thus be updated with greater frequency than the game-global ones. Properties marked as such will be persisted and restored whenever the server agent starts.

Implementation
    public function get props():PropertySubControl

See also

Constructor detail
AVRServerGameControl()constructor
public function AVRServerGameControl(serv:ServerObject)

Creates a new game control for a server agent.

Parameters
serv:ServerObject
Method detail
getPlayer()method
public function getPlayer(playerId:int):PlayerSubControlServer

Accesses the server agent's player sub control for a player with a given id. Server agents are notified when a player joins and quits the game by events. An Error is thrown if the requested player has not joined the game or has quit.

Parameters
playerId:int

Returns
PlayerSubControlServer

See also

AVRGameControlEvent.PLAYER_JOINED
AVRGameControlEvent.PLAYER_QUIT
getRoom()method 
public function getRoom(roomId:int):RoomSubControlServer

Accesses the server agent's room sub control for a given room id. This method will fail by throwing an Error if the room is not currently loaded by the server agent. A room with at least one player in it is guaranteed to be loaded. Server agents are notified of player entry and exit by events. A room with no players in it should be considered unloaded after the event is sent for the last player exiting the room.

Parameters
roomId:int

Returns
RoomSubControlServer

See also

loadOfflinePlayer()method 
public function loadOfflinePlayer(playerId:int, success:Function, failure:Function):void

Loads the property space of an offline player and calls your function with it as an argument. Within this callback, you may read and write persistent properties as you see fit. Note: To preserve some semblance of sanity, you can only load the properties of a player who has already had at least one persistent property set.

Parameters
playerId:int
 
success:Function
 
failure:Function

Example
An example, whereby one player may leave an offline message for another player:
        _ctrl.loadOfflinePlayer(opponentPlayerId, function (props :PropertySubControl) :void {
            props.setIn("messages", myPlayerId, myMessage);
        }, function (failureCause :String) :void {
            log.warn("Eek! Sending message to offline player failed!", "cause", failureCause);
       });