System Global

From Virtual World Web Wiki
Jump to: navigation, search

The System JavaScript Global object is available from server world scripts and provides utility methods for ineter-script communication among other things

  • This is a JavaScript global object named System

Remarks [edit]

Methods

bool BroadcastMessage(int channel, string message, DOMObjectExtended source)
Sends a JSScriptEVentMessage packet to all connected clients in the room. Client side UI script can process and respond to this message.
void BroadcastOnChannel(int channel, string message, DOMObjectExtended source = NULL)
Sends a message on a given channel to all listening scripts. The message an source will be passed to the listening scripts’ callback function registered with ListenOnChannel. These messages are not delivered to connected clients.
int CreateTimer(JSFlexibleFunction callback, int dueTime, int duePeriod = -1)
Creates a timer which will fire once in dueTime milliseconds and then every duePeriod milliseconds. When the timer fires, it will call the specified JavaScript callback function. An integer handle to the timer is returned.
void CreateWebRequest(string requestType, string contentType, string url, JSFlexibleFunction requestCompleted, string postdata)
Requests data from the web at the given url. requestType should be GET or POST. If POST, the postData should contain the data to post. contentType is optional and can be null or empty. The callback will be called with two parameters: the response string data, and an integer http status code (200 = success).
void Debug(string message)
An alias for Log.WriteDebug
ReturnType Exception(string message)
DOMControllerExtended FindController(DOMObjectExtended target)
If the target object is in a persona document, this method will return the document’s first DOMController.
DOMControllerExtended FindParentController(DOMObjectExtended target)
Searches up the DOM tree from target looking for the first DOMController.
ParticipantExtended FindParticipant(DOMObjectExtended target)
If the target object is in a persona document, this method will return the document’s first DOMController.
void ListenOnChannel(int channel, JSFlexibleFunction callback)
Begins listening on a given script channel number and defines a JavaScript callback to call when a message arrives from another script.
string LoadJsonResource(ResourceValue resource)
Loads and returns a JSON resource as a string
Guid NewGuid()
Generates a new GUID
void Reload()
Reloads the current script
bool RemoveTimer(int timerID)
Removes a timer given a timer handle from CreateTimer.
void ServerLog(string message)
Writes a debug message to the server log system (as opposed to the script debug system)
int SetInterval(JSFlexibleFunction callback, int duePeriod)
Creates a timer which will fire every duePeriod milliseconds. When the timer fires, it will call the specified callback function. An integer handle to the timer is returned.
int SetTimeout(JSFlexibleFunction callback, int dueTime)
Creates a timer which will fire once in dueTime milliseconds. When the timer fires, it will call the specified callback function. An integer handle to the timer is returned.
void Unload()
Unloads (ends) the current script