@zerodensity/realityhub-api 1.5.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -33,10 +33,49 @@ BrokerClient.initModule({
33
33
  });
34
34
  ```
35
35
 
36
+ ### Listing the engines
37
+
38
+ ```js
39
+ brokerClient.api.hub.reality_world.listEngines()
40
+ .then((engines) => {
41
+ console.log(engines);
42
+ })
43
+ .catch((ex) => console.trace(ex));
44
+ ```
45
+
46
+ ### Listing the nodes running on an engine
47
+
48
+ ```js
49
+ brokerClient.api.hub.reality_world.getNodes(8 /* id of the engine */)
50
+ .then((nodes) => {
51
+ console.log(nodes);
52
+ })
53
+ .catch((ex) => console.trace(ex));
54
+ ```
55
+
36
56
  ### Calling a Reality Node's Function
37
57
 
58
+ You can use `callNodeFunction(params[, engineIds])` to call a node function. `engineIds` is an array
59
+ of engine IDs. If `engineIds` is not supplied then the function will be called on all the engines.
60
+
38
61
  ```js
39
- // Node_0's PLAY function is called
62
+ /**
63
+ * @typedef FunctionProperty
64
+ * @type {object}
65
+ * @property {string} NodePath
66
+ * @property {string} PropertyPath
67
+ * @property {object} payload
68
+ * @property {*} payload.value
69
+ */
70
+
71
+ /**
72
+ * Node_0's PLAY function is called
73
+ * @param {object} params
74
+ * @param {string} params.NodePath
75
+ * @param {string} params.PropertyPath
76
+ * @param {FunctionProperty[]} [params.functionProperties] - (optional)
77
+ * @param {number} [engineIds] - (optional)
78
+ */
40
79
  brokerClient.api.hub.reality_world.callNodeFunction({
41
80
  NodePath: 'Mixer Default',
42
81
  PropertyPath: 'Default//DoTransition/0',
@@ -54,7 +93,21 @@ brokerClient.api.hub.reality_world.callNodeFunction({
54
93
 
55
94
  ### Setting a Reality Node's Property Value
56
95
 
96
+ You can use `setNodeProperty(params[, engineIds])` to set a node's property value. `engineIds` is an
97
+ array of engine IDs. If `engineIds` not supplied then all of the engines will receive the set node
98
+ property command.
99
+
57
100
  ```js
101
+ /**
102
+ * @param {object} params
103
+ * @param {string} params.NodePath
104
+ * @param {string} params.PropertyPath
105
+ * @param {*} params.Value
106
+ * @param {number} [params.Delay=0] - (optional) Delay in seconds
107
+ * @param {number} [params.Duration=0] - (optional) Duration in seconds
108
+ * @param {Jump|Linear|EaseIn|EaseOut|EaseInOut} [params.InterpType=Jump] - (optional)
109
+ * @param {number} [engineIds] - (optional)
110
+ */
58
111
  brokerClient.api.hub.reality_world.setNodeProperty({
59
112
  NodePath: 'Mixer Default',
60
113
  PropertyPath: 'Overlay Options//OverlayOpacity/0',
@@ -67,14 +120,13 @@ brokerClient.api.hub.reality_world.setNodeProperty({
67
120
  ### Subscribing to Property Change Event
68
121
 
69
122
  ```js
70
- // nodepropertyupdate event has a special sytax. You have to supply an engine name in order to
71
- // subscribe to the event. The engine name and event name is delitimed by 2 colons.
123
+ // nodepropertyupdate event has a special sytax. You have to supply an engine id and the node's path in order to
124
+ // subscribe to its property change events. The engine id, event name and node path are delitimed by 2 colons.
72
125
 
73
126
  brokerClient.api.hub.reality_world.listEngines()
74
- .then((engines) => engines[0].name)
75
- .then((engineName) => {
76
- brokerClient.api.hub.reality_world.on(`nodepropertyupdate::${engineName}`, (eventData) => {
77
- if (eventData.NodePath !== 'Mixer Default') return;
127
+ .then((engines) => engines[0].id)
128
+ .then((engineId) => {
129
+ brokerClient.api.hub.reality_world.on(`nodepropertyupdate::${engineId}::Mixer_0`, (eventData) => {
78
130
  if (eventData.property.PropertyPath !== 'Overlay Options//OverlayOpacity/0') return;
79
131
 
80
132
  console.log('New value of overlay opacity is', eventData.property.Value);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zerodensity/realityhub-api",
3
- "version": "1.5.0",
3
+ "version": "1.6.0",
4
4
  "description": "RealityHub API Javascript Implementation",
5
5
  "main": "src/index.js",
6
6
  "repository": {
@@ -123,9 +123,11 @@ module.exports = class BrokerClient extends BrokerBase {
123
123
  url = { hostname: options.host, port: options.port };
124
124
  }
125
125
 
126
+ const scheme = url.protocol === 'https:' ? 'wss' : 'ws';
127
+
126
128
  const webSocketURL = url.port
127
- ? `ws://${url.hostname}:${url.port}${this.webSocketURL}`
128
- : `ws://${url.hostname}${this.webSocketURL}`;
129
+ ? `${scheme}://${url.hostname}:${url.port}${this.webSocketURL}`
130
+ : `${scheme}://${url.hostname}${this.webSocketURL}`;
129
131
 
130
132
  this.socket = new ws(webSocketURL);
131
133
  this.addSocketListeners();