Packagenet.user1.reactor.snapshot
Classpublic class Snapshot
InheritanceSnapshot Inheritance flash.events.EventDispatcher
Subclasses AccountListSnapshot, AccountSnapshot, BannedListSnapshot, ClientCountSnapshot, ClientListSnapshot, ClientSnapshot, GatewaysSnapshot, NodeListSnapshot, RoomListSnapshot, RoomSnapshot, ServerModuleListSnapshot, UPCStatsSnapshot

Since : Reactor 1.0.0

Reactor’s "snapshots" provide a traditional request/response mechanism for retrieving data on demand from Union Server; the Snapshot class is the abstract base class for all Reactor "snapshot" classes, each of which loads a specific set of data from the server. For example, the ClientCountSnapshot class loads the number of clients currently connected to the server. The RoomSnapshot class loads a data manifest describing a particular room. To request a snapshot of data using a snapshot class, first create the desired snapshot object, then pass that object to the Reactor class's updateSnapshot() method. For example, to load a list of the roomIDs of all rooms on the server, use a RoomListSnapshot, as follows:

  1. First, create the RoomListSnapshot object:
       var snapshot:RoomListSnapshot = new RoomListSnapshot(null, true);
       
  2. Next, register a callback or listener function to be invoked automatically when the snapshot's data has loaded.
       // Register a callback function
       snapshot.onLoad = function ():void {
         trace("Here's the room list: " + snapshot.getRoomList());
       }
       
       // Or register a listener function
       snapshot.addEventListener(SnapshotEvent.LOAD, loadListener);
       function loadListener (e:SnapshotEvent):void {
         trace("Here's the room list: " + RoomListSnapshot(e.target).getRoomList());
       }
       
  3. Finally, pass the snapshot object to Reactor's updateSnapshot() method:
       reactor.updateSnapshot(snapshot);
       

Snapshots such as the preceding RoomListSnapshot object represent the state of the server at the time of the updateSnapshot() request only, and are not kept synchronized once loaded. By contrast, to maintain synchronization between Union Server and Reactor, use the classes in the main Reactor API (net.user1.reactor). For example, to maintain a synchronized list of rooms, use RoomManager's watchForRooms() method rather than a RoomListSnapshot object.

All snapshot objects trigger SnapshotEvent.LOAD when data loads. Some snapshot objects also trigger SnapshotEvent.STATUS when the status of the load operation is received. For details, see SnapshotEvent.

See also

SnapshotEvent
AccountSnapshot
AccountListSnapshot
ClientSnapshot
ClientListSnapshot
ClientCountSnapshot
RoomSnapshot
RoomListSnapshot
net.user1.reactor.Reactor.updateSnapshot()


Public Variables
 VariableDefined By
  onLoad : Function
A callback function to be invoked when this snapshot's data is loaded.
Snapshot
Public Methods
 MethodDefined By
  
Constructor
Snapshot
  
getStatus():String
Returns the status of the most recent snapshot load-operation.
Snapshot
  
Indicates whether the snapshot is currently loading data.
Snapshot
Events
 Event Summary Defined By
   Dispatched when a snapshot object has been updated in response to an earlier call to Reactor's updateSnapshot() method.Snapshot
   Dispatched when the result of an update request has been received by a snapshot object.Snapshot
Variable Descriptions
onLoadvariable
public var onLoad:Function

Since : Reactor 1.0.0

A callback function to be invoked when this snapshot's data is loaded.

See also

Constructor Description
Snapshot()Constructor
public function Snapshot()

Constructor

Method Descriptions
getStatus()method
public function getStatus():String

Since : Reactor 1.0.0

Returns the status of the most recent snapshot load-operation. If a load operation is currently in progress, getStatus() returns null. The possible return values of getStatus() depend on the snapshot type, as follows:

AccountListSnapshot

AccountSnapshot BannedListSnapshot ClientCountSnapshot ClientListSnapshot ClientSnapshot RoomListSnapshot RoomSnapshot UPCStatsSnapshot

Returns
String

See also

updateInProgress()method 
public function updateInProgress():Boolean

Since : Reactor 1.0.0

Indicates whether the snapshot is currently loading data. While an update is in progress, further requests to update the snapshot are ignored.

Returns
Boolean
Event Detail
LOAD Event
Event Object Type: SnapshotEvent
SnapshotEvent.type variable = net.user1.reactor.snapshot.SnapshotEvent.LOAD

Dispatched when a snapshot object has been updated in response to an earlier call to Reactor's updateSnapshot() method.

See also

STATUS Event  
Event Object Type: SnapshotEvent
SnapshotEvent.type variable = net.user1.reactor.snapshot.SnapshotEvent.STATUS

Dispatched when the result of an update request has been received by a snapshot object.

See also