Class: VRSpace

VRSpace()

Main client API class, no external dependencies. Provides send methods to send messages to the server, to be distributed to other clients. Listeners receive remote events.

Constructor

new VRSpace()

Source:

Classes

VRSpace

Members

debug

Debug logging, default false
Source:

me

Representation of own Client, available once connection is established
Source:

scene

Map containing all objects in the scene
Source:

ws

Underlying websocket
Source:

Methods

addConnectionListener()

Add a connection listener that gets notified when connection is activated/broken. Callback is passed boolean argument indicating connection state.
Source:

addDataListener()

Add a data listener that receives everything from the server (JSON string argument)
Source:

addErrorListener()

Add error listener, notified when server sends error notifications. Error listener is passed the string containing the server error message, e.g. java exception.
Source:

addSceneListener()

Add a scene listener that gets notified when the scene is changed. Scene listeners receive SceneEvent argument for each change.
Source:

addWelcomeListener()

Add a Welcome listener, notified when entering a world. The listener receives Welcome object.
Source:

call(message, callback)

Perform a synchronous call.
Parameters:
Name Type Description
message JSON string to send
callback function to execute upon receiving the response
Source:

connect(url)

Connect to the server, attach listeners.
Parameters:
Name Type Description
url optional websocket url, defaults to /vrspace on the same server
Source:

createField()

Create a local field of an object existing on the server FIXME Obsolete
Source:

createSharedObject(obj, callback, className)

Share an object.
Parameters:
Name Type Description
obj the new VRObject, containing all properties
callback called when shared object is received
className optional class name to create, defaults to obj.className if exists, otherwise VRObjects
Source:

deleteSharedObject(obj, callback)

Delete a shared object.
Parameters:
Name Type Description
obj to be removed from the server
callback optional, called after removal from the server
Source:

disconnect()

Disconnect, notify connection listeners
Source:

getScene(filter)

Return the current scene, optionally filtered
Parameters:
Name Type Description
filter string to match current members, usually class name
Source:

newInstance(className)

Factory method
Parameters:
Name Type Description
className shared class name
Source:
Returns:
new shared object instance

receive()

Called when a message is received from the server. JSON message is converted to an object, then depending on object type, handled as one of: message to an object in the scene, add an object message, remove an object, error message, response to a command
Source:

removeSceneListener()

Remove a scene listener.
Source:

removeWelcomeListener(callback)

Remove welcome listener
Parameters:
Name Type Description
callback listener to remove
Source:

sendChanges(obj, changes)

Send changes to an object
Parameters:
Name Type Description
obj VRObject that changes
changes array containing field/value pairs
Source:

sendCommand(command, args)

Send a command to the server
Parameters:
Name Type Description
command to execute
args optional object with command arguments
Source:

sendEvent(obj, changes)

Send changes to an object
Parameters:
Name Type Description
obj VRObject that changes
changes object containing changed fields
Source:

sendMy(field, value)

Send notification of own property changes
Parameters:
Name Type Description
field name of member variable that has changed
value new field value
Source:

sendMyChanges(changes)

Send changes to own avatar
Parameters:
Name Type Description
changes array with field/value pairs
Source:

sendMyEvent(changes)

Send changes to own avatar
Parameters:
Name Type Description
changes object containing changed field(s)
Source:

stringifyPair(field, value)

Convert a key/value pair to json string
Parameters:
Name Type Description
field name of the field
value string, object or number to convert
Source:

stringifyQuaternion(vec)

Convert a quaternion to json string
Parameters:
Name Type Description
vec object having x,y,z,w properties
Source:

stringifyVector(vec)

Convert a vector to json string
Parameters:
Name Type Description
vec object having x,y,z properties
Source: