Package | com.whirled.game |
Class | public class NetSubControl |
Inheritance | NetSubControl ![]() ![]() ![]() |
Implements | PropertySubControl |
See also
Property | Defined by | ||
---|---|---|---|
agent : MessageSubControl
[read-only]
Provides a control with which to send messages to the server agent.
| NetSubControl | ||
players : MessageSubControl
[read-only]
Provides a control with which to send messages to all the players of this game, excluding
any agent.
| NetSubControl |
Property | Defined by | ||
---|---|---|---|
_agentMsgCtrl : MessageSubControl | NetSubControl | ||
_playerCtrls : Map | NetSubControl | ||
_playersMsgCtrl : MessageSubControl | NetSubControl |
Method | Defined by | ||
---|---|---|---|
![]() |
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
Registers an event listener.
| AbstractControl | |
![]() |
doBatch(fn:Function, ... args):void
Execute the specified function as a batch of commands that will be sent to the server
together.
| AbstractSubControl | |
get(propName:String):Object
| NetSubControl | ||
getPlayer(playerId:int):MessageSubControl
Provides a per-player way to send messages to a specific player.
| NetSubControl | ||
getPropertyNames(prefix:String = ""):Array
Get the names of all currently-set properties that begin with the specified prefix.
| NetSubControl | ||
![]() |
isConnected():Boolean
Are we connected and running inside the whirled environment, or has someone just
loaded up our SWF by itself?
| AbstractSubControl | |
![]() |
removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
Unregisters an event listener.
| AbstractControl | |
sendMessage(messageName:String, value:Object, playerId:int):void
Send a "message" to other clients subscribed to the game.
| NetSubControl | ||
set(propName:String, value:Object, immediate:Boolean = false):void
| NetSubControl | ||
setAt(propName:String, index:int, value:Object, immediate:Boolean = false):void
Update one element of an Array.
Note: Unlike setIn(), this update will fail silently if the index is out of bounds or if there is no array currently set at the specified property name. | NetSubControl | ||
setIn(propName:String, key:int, value:Object, immediate:Boolean = false):void
Update one element of a Dictionary.
Note: Unlike setAt(), this will usually work. | NetSubControl | ||
testAndSet(propName:String, newValue:Object, testValue:Object):void
Set a property that will be distributed, but only if it's equal to the specified test value.
| NetSubControl |
Event | Summary | Defined by | ||
---|---|---|---|---|
Dispatched when an element inside a property has changed in the shared game state. | NetSubControl | |||
Dispatched when a message arrives with information that is not part of the shared game state. | NetSubControl | |||
Dispatched when a property has changed in the shared game state. | NetSubControl | |||
![]() | Event.UNLOAD Dispatched when the SWF using this control has been unloaded. | AbstractControl |
Constant | Defined by | ||
---|---|---|---|
TO_ALL : int = 0 [static]
Constant provided to
sendMessage that will send a message to all subscribers. | NetSubControl | ||
TO_SERVER_AGENT : int = -2.147483648E9 [static]
Constant provided to
sendMessage that will send a message to the game's server
agent, if there is one. | NetSubControl |
Constant | Defined by | ||
---|---|---|---|
EXCLUDE_AGENT : int = -2.147483647E9 [static] A special constant for sending a message to players only, and not the agent.
| NetSubControl |
agent | property |
agent:MessageSubControl
[read-only]Provides a control with which to send messages to the server agent.
Implementation public function get agent():MessageSubControl
See also
_agentMsgCtrl | property |
protected var _agentMsgCtrl:MessageSubControl
_playerCtrls | property |
protected var _playerCtrls:Map
players | property |
players:MessageSubControl
[read-only]Provides a control with which to send messages to all the players of this game, excluding any agent.
Implementation public function get players():MessageSubControl
See also
_playersMsgCtrl | property |
protected var _playersMsgCtrl:MessageSubControl
get | () | method |
public function get(propName:String):Object
Parameters
propName:String |
Object |
getPlayer | () | method |
public function getPlayer(playerId:int):MessageSubControl
Provides a per-player way to send messages to a specific player.
ParametersplayerId:int |
MessageSubControl |
See also
getPropertyNames | () | method |
public function getPropertyNames(prefix:String = ""):Array
Get the names of all currently-set properties that begin with the specified prefix. Calling this method results in no network traffic.
Parametersprefix:String (default = " ")
|
Array |
sendMessage | () | method |
public function sendMessage(messageName:String, value:Object, playerId:int):void
Send a "message" to other clients subscribed to the game. These is similar to setting a property, except that the value will not be saved- it will merely end up coming out as a MessageReceivedEvent.
ParametersmessageName:String — The message to send.
|
|
value:Object — The value to attach to the message.
|
|
playerId:int — if TO_ALL (or unset), sends to everyone (including the agent),
otherwise the message will be private to just one player; if the game employs a server agent,
TO_SERVER_AGENT may be used to send a message only to the server.
|
See also
set | () | method |
public function set(propName:String, value:Object, immediate:Boolean = false):void
Parameters
propName:String |
|
value:Object |
|
immediate:Boolean (default = false )
|
setAt | () | method |
public function setAt(propName:String, index:int, value:Object, immediate:Boolean = false):void
Update one element of an Array.
Note: Unlike setIn(), this update will fail silently if the index is out of
bounds or if there is no array currently set at the specified property name.
Furthermore, if you set the element with immediate=true, there are two updates:
one locally that happens right away and the update on the server that will be
dispatched back to all the clients. Either or both can fail, so be sure to set the Array up
first using set().
propName:String — the name of the property to modify.
|
|
index:int — the array index of the element to update.
|
|
value:Object — the value to set.
|
|
immediate:Boolean (default = false ) — if true, the value is updated immediately in the local object. Otherwise
any old value will remain in effect until the ElementChangedEvent arrives after
a round-trip to the server.
|
setIn | () | method |
public function setIn(propName:String, key:int, value:Object, immediate:Boolean = false):void
Update one element of a Dictionary.
Note: Unlike setAt(), this will usually work. No key is out of range, obviously,
and if you set a value in a property that was previously null, a new Dictionary will
be created to hold your value. If a non-Dictionary property is already stored with the
specified name then this will fail silently on the server. But: don't do that!
It would be pretty bad style to store two different types of property under the same name.
propName:String — the name of the property to modify.
|
|
key:int — the key of the element to update.
|
|
value:Object — the value to set. Passing null removes the specified key from the Dictionary.
|
|
immediate:Boolean (default = false ) — if true, the value is updated immediately in the local object. Otherwise
any old value will remain in effect until the ElementChangedEvent arrives after
a round-trip to the server.
|
testAndSet | () | method |
public function testAndSet(propName:String, newValue:Object, testValue:Object):void
Set a property that will be distributed, but only if it's equal to the specified test value.
Please note that there is no way to test and set a property immediately, because the value must be sent to the server to perform the test.
The operation is 'atomic', in the sense that testing and setting take place during the same server event. In comparison, a separate 'get' followed by a 'set' operation would first read the current value as seen on your client and then send a request to overwrite any value with a new value. By the time the 'set' reaches the server the old value may no longer be valid. Since that's sketchy, we have this method.
ParameterspropName:String |
|
newValue:Object |
|
testValue:Object |
ElemChanged | event |
com.whirled.net.ElementChangedEvent
com.whirled.net.ElementChangedEvent.ELEMENT_CHANGED
Dispatched when an element inside a property has changed in the shared game state. This event is a result of calling setIn() or setAt().
The type of an ElementChangedEvent.
MsgReceived | event |
com.whirled.net.MessageReceivedEvent
com.whirled.net.MessageReceivedEvent.MESSAGE_RECEIVED
Dispatched when a message arrives with information that is not part of the shared game state.
The type of all MessageReceivedEvents.
PropChanged | event |
com.whirled.net.PropertyChangedEvent
com.whirled.net.PropertyChangedEvent.PROPERTY_CHANGED
Dispatched when a property has changed in the shared game state. This event is a result of calling set() or testAndSet().
The type of a property change event.
EXCLUDE_AGENT | constant |
protected static const EXCLUDE_AGENT:int = -2.147483647E9
A special constant for sending a message to players only, and not the agent.
TO_ALL | constant |
public static const TO_ALL:int = 0
Constant provided to sendMessage
that will send a message to all subscribers.
See also
TO_SERVER_AGENT | constant |
public static const TO_SERVER_AGENT:int = -2.147483648E9
Constant provided to sendMessage
that will send a message to the game's server
agent, if there is one.
See also