State instances wrap the state sync and connection with the Max backend.
Name | Type | Description | ||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
|
Members
-
connectionState:number
readonly -
Returns the current connection state.
- See:
-
hostname:string
readonly -
Hostname of the Max WebSocket.
-
isMotionEnabled:boolean
readonly -
Returns whether motion tracking is currently enabled/disabled.
-
isStateLoaded:boolean
readonly -
Returns whether the initial state has been received from Max and loaded.
-
name:string
-
Name of the current xebra connection. For some Max objects, like mira.motion and mira.multitouch, multiple xebra clients (connected via Xebra.js or the Mira iOS app) can send events to the same object. This name property will be appended to these events, so that the events can be routed in Max.
-
port:number
readonly -
Returns the port number of the Max WebSocket.
-
uuid:string
readonly -
UUID associated with this state.
-
wsUrl:string
readonly -
WebSocket connection URL.
Methods
-
Closes the Xebra connection and resets the state.
-
Connects to the Xebra server. If
auto_connect : true
is passed to State on. -
Create a Resource, which can be used to retrieve image data from the Max search path.
Returns:
Type Description Resource -
Returns a list of the names of all mira.channel objects in all patchers
Returns:
Type Description Array.<string> -
getObjectById(id):ObjectNode|null
-
Returns the object speficied by the given id.
Name Type Description id
Xebra.NodeId The id of the object
Returns:
Type Description ObjectNode | null the object or null if not known -
getObjectsByScriptingName():Array.<ObjectNode>
-
Returns a list of node objects with the given scripting name (the Max attribute 'varname').
Returns:
Type Description Array.<ObjectNode> -
getPatcherById(id):PatcherNode|null
-
Returns the patcher speficied by the given id.
Name Type Description id
Xebra.NodeId The id of the patcher
Returns:
Type Description PatcherNode | null the patcher or null if not known -
getPatchers():Array.<PatcherNode>
-
Returns a list of available patchers.
Returns:
Type Description Array.<PatcherNode> -
Send an arbitrary message to the named channel. The type of the message will be coerced to a Max type in the Max application by mira.channel
Name Type Description channel
String The name of the mira.channel objects that should receive this message
message
Number | String | Array.<(Number|String)> | Object the message to send
-
Send mira.motion updates to parameters on the root node.
Name Type Description motionType
string The type of motion
motionX
number motionY
number motionZ
number timestamp
number - See:
Throws:
Will throw an error when motion is currently disabled on the instance of State.
Events
-
This event is emitted when a message is sent to a mira.channel object
Name Type Description channel
String The name of the channel where the message was received
message
Number | String | Array.<(Number|String)> | Object The message received from Max
-
This event is emitted when the state of the web socket connection to the Max patch (ConnectionState) changes.
-
This event is emitted when a frame is added in Max.
Name Type Description object
FrameNode The added frame
-
This event is emitted when a parameter of a frame is changed. This change can come from Max or when the value of the parameter is set directly.
Name Type Description frame
FrameNode The changed frame
param
ParamNode The parameter node
-
This event is emitted when a frame is removed from Max.
Name Type Description object
FrameNode The removed frame
-
This event is emitted when the entire Max state has been loaded. At this point, all
frame_added
,object_added
, andpatcher_added
events will have fired, and all of their parameters will have been loaded. This is analogous to $(document).ready() in jQuery. -
This event is emitted when the last mira.motion object is removed from Max. This event is not emitted when xebra first connects to Max, and there are no mira.motion objects in Max.
-
This event is emitted when there is at least one mira.motion object in Max.
-
This event is emitted when an object is added in Max.
Name Type Description object
ObjectNode The added object
-
This event is emitted when a parameter of an object is changed. This change can come from Max or when the value of the parameter is set directly.
Name Type Description object
ObjectNode The changed object
param
ParamNode The parameter node
-
This event is emitted when an object is removed from Max.
Name Type Description object
ObjectNode The removed object
-
This event is emitted when a patcher is added in Max.
Name Type Description object
PatcherNode The added patcher
-
This event is emitted when a parameter of a patcher is changed. This change can come from Max or when the value of the parameter is set directly.
Name Type Description patcher
PatcherNode The changed patcher
param
ParamNode The parameter node
-
This event is emitted when a patcher is removed from Max.
Name Type Description object
PatcherNode The removed patcher
-
This event is emitted when the web socket connection is persistently interrupted to the point that the xebra state and Max state fall out of sync. In this case, xebra will attempt to reset and rebuild the state, which fires this event. This should happen very infrequently. A state#loaded event will fire when this event fires.