Package | net.user1.reactor |
Class | public class Server |
Inheritance | Server ![]() |
Since : | Reactor 1.0.0 |
See also
Method | Defined By | ||
---|---|---|---|
Server | |||
clearModuleCache():void
Asks the server to remove all current module class definitions from memory. | Server | ||
getServerTime():Number
Returns the approximate current time on the server in UTC, using
"milliseconds from January 1 1970" format. | Server | ||
Returns the version of the UPC protocol in use by Union Server. | Server | ||
getVersion():String
Returns the version of the Union Server to which Reactor is currently
connected. | Server | ||
isWatchingForProcessedUPCs():Boolean
Indicates whether the current client is currently watching for processed
UPCs. | Server | ||
resetUPCStats():void
Asks Union Server to reset server-side UPC-processing statistics. | Server | ||
sendMessage(messageName:String, includeSelf:Boolean = false, filters:IFilter = null, ... rest):void
Sends a message to the entire server. | Server | ||
sendModuleMessage(moduleID:String, messageName:String, messageArguments:Object = null):void
Sends the specified message to the specified server module. | Server | ||
setIsWatchingForProcessedUPCs(value:Boolean):void | Server | ||
stopWatchingForProcessedUPCs():void
Asks the server to stop sending UPC-processing notifications. | Server | ||
syncTime():void
Asks the server to send the current time. | Server | ||
watchForProcessedUPCs():void
Asks the server to notify the current client upon processing any UPC
message. | Server |
Event | Summary | Defined By | ||
---|---|---|---|---|
Dispatched when the server reports the result of a stop-watching-for-processed-UPCs attempt by the current client. | Server | |||
Dispatched when the server sends the current server time in response to an earlier invocation of Server's syncTime() method by the current client. | Server | |||
Dispatched when the current client is watching for "processed UPC messages" and the server finishes processing an inbound UPC message. | Server | |||
Dispatched when the server reports the result of a watch-for-processed-UPCs attempt by the current client. | Server |
Server | () | Constructor |
clearModuleCache | () | method |
public function clearModuleCache():void
Since : | Reactor 1.0.2 |
Asks the server to remove all current module class definitions from memory. Subsequently instantiated modules will use the newly loaded module class definitions, allowing module developers to update Union Server's modules at runtime without restarting the server. Note that currently running modules are not reloaded. For example, if a room module is already active for a room, clearModuleCache() will not affect that module. If the active module's class file has changed and clearModuleCache() is invoked, then the new class definition will not be used until the next time the room is removed and recreated.
The clearModuleCache() method does not affect script modules. Union Server always uses the latest version of all script modules on disk, so there is no script module cache to clear.
reactor.getServer().clearModuleCache();
getServerTime | () | method |
public function getServerTime():Number
Since : | Reactor 1.0.0 |
Returns the approximate current time on the server in UTC, using "milliseconds from January 1 1970" format. The time is approximated by adding the following two values:
To retrieve the most accurate possible approximation, first call syncTime(), then call getServerTime() from within the ServerEvent.TIME_SYNC callback.
ReturnsNumber |
See also
getUPCVersion | () | method |
public function getUPCVersion():VersionNumber
Since : | Reactor 1.0.0 |
Returns the version of the UPC protocol in use by Union Server. For protocol information, see the UPC Specification.
ReturnsVersionNumber |
getVersion | () | method |
public function getVersion():String
Since : | Reactor 1.0.0 |
Returns the version of the Union Server to which Reactor is currently connected.
ReturnsString |
isWatchingForProcessedUPCs | () | method |
public function isWatchingForProcessedUPCs():Boolean
Since : | Reactor 1.1.0 |
Indicates whether the current client is currently watching for processed UPCs.
ReturnsBoolean |
See also
resetUPCStats | () | method |
public function resetUPCStats():void
Since : | Reactor 1.1.0 |
Asks Union Server to reset server-side UPC-processing statistics. If the request is granted, Union Server clears its list of the longest UPC-message-processing times. The statistics-reset is reflected in any subsequent UPCStatsSnapshot retrieval. By default, resetUPCStats() requires administrator privileges.
See also
sendMessage | () | method |
public function sendMessage(messageName:String, includeSelf:Boolean = false, filters:IFilter = null, ... rest):void
Since : | Reactor 1.0.0 |
Sends a message to the entire server.
To receive the message, recipient clients must register a message listener via MessageManager's addMessageListener() method.
The following code sends a message named "HELLO" to all clients on the server.connection.getServer().sendMessage("HELLO", true, null, "Hi everyone!");
connection.getMessageManager().addMessageListener("HELLO", helloListener);
public function helloListener (fromClient:IClient, message:String):void { trace("Received message: " + message); }
Parameters
messageName:String — The name of the message to invoke.
| |
includeSelf:Boolean (default = false ) — Indicates whether to send the message to the current
client (i.e., the client that invoked sendMessage()).
Defaults to false (don't echo to the sender).
| |
filters:IFilter (default = null ) — Specifies one or more filters for the message. A
filter specifies a requirement that each client must
meet in order to receive the message. For example, a
filter might indicate that only those clients with
the attribute "team" set to "red" should receive the
message. For complete details, see the Filter class.
If filters is null, all clients on the server receive the message.
| |
... rest — An optional comma-separated list of string arguments for
the message. These will be passed to any listeners
registered to receive the message. See
MessageManager's addMessageListener() method.
|
See also
sendModuleMessage | () | method |
public function sendModuleMessage(moduleID:String, messageName:String, messageArguments:Object = null):void
Since : | Reactor 1.0.0 |
Sends the specified message to the specified server module.
For information on server modules, see Union Server's modules documentation.
Parameters
moduleID:String — The ID of the module to which the message will be sent. Modules
are assigned IDs in the server's union.xml configuration file,
via the module <id> tag.
For example, the following union.xml excerpt shows the deployment
of a module whose ID is serverStatsServerModule.
<modules> <module> <id>serverStatsServerModule</id> <source type="class">net.user1.union.servermodule.ServerStatsServerModule</source> <attributes> <attribute name="interval">300</attribute> </attributes> </module> </modules> | |
messageName:String — The name of the message to send.
| |
messageArguments:Object (default = null ) — The message arguments, specified as dynamic instance
variables on a generic object.
|
See also
// Send message "setRefreshRate" with argument "rate" set to "2000". var messageArguments:Object = new Object(); messageArguments.rate = "2000"; connection.getServer().sendModuleMessage("setRefreshRate", messageArguments); // Same thing, but using object-literal syntax. connection.getServer().sendModuleMessage("setRefreshRate", {rate:"2000"});
setIsWatchingForProcessedUPCs | () | method |
public function setIsWatchingForProcessedUPCs(value:Boolean):void
Parameters
value:Boolean |
stopWatchingForProcessedUPCs | () | method |
public function stopWatchingForProcessedUPCs():void
Since : | Reactor 1.1.0 |
Asks the server to stop sending UPC-processing notifications. By default, stopWatchingForProcessedUPCs() requires administrator privileges.
See also
syncTime | () | method |
public function syncTime():void
Since : | Reactor 1.0.0 |
Asks the server to send the current time. When the time is received, ServerEvent.TIME_SYNC fires. Use getServerTime() to retrieve the current approximate time on the server (i.e., the last sync time plus elapsed time on the client). If syncTime() has never been called, getServerTime() returns the client connection time plus time elapsed on the client.
See also
watchForProcessedUPCs | () | method |
public function watchForProcessedUPCs():void
Since : | Reactor 1.1.0 |
Asks the server to notify the current client upon processing any UPC message. Notifications trigger the ServerEvent.UPC_PROCESSED event. Details about each message processed are provided in a UPCProcessingRecord accessble via the ServerEvent's getUPCProcessingRecord() method. By default, watchForProcessedUPCs() requires administrator privileges.
See also
STOP_WATCHING_FOR_PROCESSED_UPCS_RESULT | Event |
ServerEvent
net.user1.reactor.ServerEvent.STOP_WATCHING_FOR_PROCESSED_UPCS_RESULT
Dispatched when the server reports the result of a stop-watching-for-processed-UPCs attempt by the current client. To determine the result of the attempt, use getStatus(), which has the following possible return values:
See also
TIME_SYNC | Event |
ServerEvent
net.user1.reactor.ServerEvent.TIME_SYNC
Dispatched when the server sends the current server time in response to an earlier invocation of Server's syncTime() method by the current client. Listeners for ServerEvent.TIME_SYNC can retreive the approximate time on the server via Server's getServerTime() method, as follows:
protected function timeSyncListener (e:ServerEvent):void { trace("Time is: " + Server(e.target).getServerTime()); }
See also
UPC_PROCESSED | Event |
ServerEvent
net.user1.reactor.ServerEvent.UPC_PROCESSED
Dispatched when the current client is watching for "processed UPC messages" and the server finishes processing an inbound UPC message. To watch for processed UPC messages, use the Server class's watchForProcessedUPCs() method. For example,
reactor.getServer().watchForProcessedUPCs();
See also
WATCH_FOR_PROCESSED_UPCS_RESULT | Event |
ServerEvent
net.user1.reactor.ServerEvent.WATCH_FOR_PROCESSED_UPCS_RESULT
Dispatched when the server reports the result of a watch-for-processed-UPCs attempt by the current client. To determine the result of the attempt, use getStatus(), which has the following possible return values:
See also