Package | net.user1.reactor.snapshot |
Class | public class Snapshot |
Inheritance | Snapshot ![]() |
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:
var snapshot:RoomListSnapshot = new RoomListSnapshot(null, true);
// 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()); }
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
Variable | Defined By | ||
---|---|---|---|
onLoad : Function
A callback function to be invoked when this snapshot's data is loaded. | Snapshot |
Method | Defined By | ||
---|---|---|---|
Snapshot()
Constructor
| Snapshot | ||
getStatus():String
Returns the status of the most recent snapshot load-operation. | Snapshot | ||
updateInProgress():Boolean
Indicates whether the snapshot is currently loading data. | Snapshot |
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 |
onLoad | variable |
public var onLoad:Function
Since : | Reactor 1.0.0 |
A callback function to be invoked when this snapshot's data is loaded.
See also
Snapshot | () | Constructor |
public function Snapshot()
Constructor
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
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.
ReturnsBoolean |
LOAD | Event |
SnapshotEvent
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 |
SnapshotEvent
net.user1.reactor.snapshot.SnapshotEvent.STATUS
Dispatched when the result of an update request has been received by a snapshot object.
See also