@zerodensity/realityhub-api 1.10.0 → 1.15.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.
@@ -19,4 +19,3 @@ jobs:
19
19
  registry-url: https://registry.npmjs.org/
20
20
  - run: npm ci
21
21
  - run: npm publish
22
- - run: npm publish --tag latest
@@ -0,0 +1,7 @@
1
+ # Contributing to RealityHub Open-Source SDK
2
+
3
+ Thank you for your interest in contributing to RealityHub Open-Source SDK!
4
+
5
+ ## Contribution Guidelines
6
+
7
+ At this time, external contributions are not being accepted. We appreciate your understanding and your support of the RealityHub Open-Source SDK!
package/README.md CHANGED
@@ -30,72 +30,87 @@ BrokerClient.initModule({
30
30
  serverURL: '<your backend module>',
31
31
  hub: {
32
32
  host: '127.0.0.1',
33
- port: 3000,
33
+ port: 80,
34
34
  },
35
35
  }).then((brokerClient) => {
36
36
  // brokerClient is connected to RealityHub and ready to use
37
37
  });
38
38
  ```
39
39
 
40
- ### Listing the engines
40
+ ### Listing Reality 5 (API v1.2+) engines
41
41
 
42
42
  ```js
43
- brokerClient.api.hub.reality_world.listEngines()
43
+ brokerClient.api.hub.reality5_1_2_world.listEngines()
44
44
  .then((engines) => {
45
45
  console.log(engines);
46
+
47
+ /**
48
+ * [
49
+ * {
50
+ * ip: '172.16.1.181',
51
+ * port: 50052,
52
+ * id: 79,
53
+ * name: 'ZDHQ-HUB-AMPERE',
54
+ * ready: true,
55
+ * status: 'connected',
56
+ * fps: '', // If there is no UE5 node, FPS will be an empty string
57
+ * engineType: 'RE5_1_2'
58
+ * }
59
+ * ]
60
+ */
46
61
  })
47
62
  .catch((ex) => console.trace(ex));
48
63
  ```
49
64
 
50
- ### Listing the nodes running on an engine
65
+ ### Listing the nodes running on an Reality 5 engine (API v1.2+)
51
66
 
52
67
  ```js
53
- brokerClient.api.hub.reality_world.getNodes(8 /* id of the engine */)
68
+ brokerClient.api.hub.reality5_1_2_world.getNodes(79 /* id of the engine */)
54
69
  .then((nodes) => {
55
70
  console.log(nodes);
71
+
72
+ /**
73
+ * {
74
+ * ...
75
+ * // The keys are the NodePath
76
+ * Cyclorama: {
77
+ * ...
78
+ * Functions: {
79
+ * // The keys are the FunctionPath
80
+ * 'Cyclorama/AddProjection': {...},
81
+ * 'Cyclorama/ClearProjection': {...},
82
+ * }
83
+ * ...
84
+ * }
85
+ * ...
86
+ * }
87
+ */
88
+
89
+ // NOTE: For backward compatiblity, the NodePath and FunctionPath omit the leading '/'.
56
90
  })
57
91
  .catch((ex) => console.trace(ex));
58
92
  ```
59
93
 
60
- ### Calling a Reality Node's Function
94
+ ### Calling a Node's Function
61
95
 
62
96
  You can use `callNodeFunction(params[, engineIds])` to call a node function. `engineIds` is an array
63
97
  of engine IDs. If `engineIds` is not supplied then the function will be called on all the engines.
64
98
 
65
99
  ```js
66
100
  /**
67
- * @typedef FunctionProperty
68
- * @type {object}
69
- * @property {string} NodePath
70
- * @property {string} PropertyPath
71
- * @property {object} payload
72
- * @property {*} payload.value
73
- */
74
-
75
- /**
76
- * Node_0's PLAY function is called
101
+ * Cyclorama's Add Projection function is called
77
102
  * @param {object} params
78
103
  * @param {string} params.NodePath
79
104
  * @param {string} params.PropertyPath
80
- * @param {FunctionProperty[]} [params.functionProperties] - (optional)
81
- * @param {number} [engineIds] - (optional)
105
+ * @param {number} [engineIds] - optional, default is all engines
82
106
  */
83
- brokerClient.api.hub.reality_world.callNodeFunction({
84
- NodePath: 'Mixer Default',
85
- PropertyPath: 'Default//DoTransition/0',
86
- functionProperties: [
87
- {
88
- NodePath: 'Mixer Default',
89
- PropertyPath: 'Default/DoTransition/Duration/0',
90
- payload: {
91
- value: 8,
92
- },
93
- },
94
- ],
95
- }).catch((ex) => console.trace(ex));
107
+ brokerClient.api.hub.reality5_1_2_world.callNodeFunction({
108
+ NodePath: '/Cyclorama',
109
+ FunctionPath: '/Cyclorama/AddProjection',
110
+ }, [/* engine id = */ 79]).catch((ex) => console.trace(ex));
96
111
  ```
97
112
 
98
- ### Setting a Reality Node's Property Value
113
+ ### Setting a Node's Property Value
99
114
 
100
115
  You can use `setNodeProperty(params[, engineIds])` to set a node's property value. `engineIds` is an
101
116
  array of engine IDs. If `engineIds` not supplied then all of the engines will receive the set node
@@ -107,36 +122,46 @@ property command.
107
122
  * @param {string} params.NodePath
108
123
  * @param {string} params.PropertyPath
109
124
  * @param {*} params.Value
110
- * @param {number} [params.Delay=0] - (optional) Delay in seconds
111
- * @param {number} [params.Duration=0] - (optional) Duration in seconds
112
- * @param {Jump|Linear|EaseIn|EaseOut|EaseInOut} [params.InterpType=Jump] - (optional)
113
125
  * @param {number} [engineIds] - (optional)
114
126
  */
115
- brokerClient.api.hub.reality_world.setNodeProperty({
116
- NodePath: 'Mixer Default',
117
- PropertyPath: 'Overlay Options//OverlayOpacity/0',
127
+ brokerClient.api.hub.reality5_1_2_world.setNodeProperty({
128
+ NodePath: '/Add_f32',
129
+ PropertyPath: 'X',
118
130
  Value: 0.240,
119
- InterpType: 'EaseOut',
120
- Duration: 1,
121
- }).catch((ex) => console.trace(ex));
131
+ }, [/* engine id = */ = 79]).catch((ex) => console.trace(ex));
122
132
  ```
123
133
 
124
- ### Subscribing to Property Change Event
134
+ ### Interpolating a Node's Property Value
135
+
136
+ You can use `interpolate(params[, engineIds])` to interpolate a node's property value. `engineIds` is an array of engine IDs. If `engineIds` not supplied then all of the engines will receive the same interpolate command.
125
137
 
126
138
  ```js
127
- // nodepropertyupdate event has a special sytax. You have to supply an engine id and the node's path in order to
128
- // subscribe to its property change events. The engine id, event name and node path are delitimed by 2 colons.
139
+ brokerClient.api.hub.reality5_1_2_world.interpolate({
140
+ NodePath: '/Add_f32',
141
+ PropertyPath: 'X',
142
+ StartValue: 5.0, // optional, default is the current value
143
+ EndValue: 10.0,
144
+ Duration: 2000, // in milliseconds, optional, default is 0
145
+ Delay: 2000, // in milliseconds, optional, default is 0
146
+
147
+ /** @type {'Jump' | 'Linear' | 'EaseIn' | 'EaseOut' | 'EaseInOut'} */
148
+ InterpType: 'EaseIn', // optional, default is 'Jump'
149
+ }, [/* engine id = */ 79]).catch((ex) => console.trace(ex));
150
+ ```
129
151
 
130
- brokerClient.api.hub.reality_world.listEngines()
131
- .then((engines) => engines[0].id)
132
- .then((engineId) => {
133
- brokerClient.api.hub.reality_world.on(`nodepropertyupdate::${engineId}::Mixer_0`, (eventData) => {
134
- if (eventData.property.PropertyPath !== 'Overlay Options//OverlayOpacity/0') return;
152
+ ### Getting a Node's Property Value
135
153
 
136
- console.log('New value of overlay opacity is', eventData.property.Value);
137
- });
138
- })
139
- .catch((ex) => console.trace(ex));
154
+ You can use `getNodeProperty(params[, engineIds])` to get a node's property value. `engineIds` is an array of engine IDs. If `engineIds` not supplied then all of the engines will be queried. That is why this method returns an array of promises.
155
+
156
+ ```js
157
+ brokerClient.api.hub.reality5_1_2_world.getNodeProperty(
158
+ { NodePath: '/Add_f32', PropertyPath: 'X', },
159
+ [/* engine id = */ 79]
160
+ )
161
+ .then((results) => {
162
+ console.log(results[0].Value);
163
+ })
164
+ .catch((ex) => console.trace(ex));
140
165
  ```
141
166
 
142
167
  ### Registering Your Own Methods to RealityHub
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zerodensity/realityhub-api",
3
- "version": "1.10.0",
3
+ "version": "1.15.0",
4
4
  "description": "RealityHub API Javascript Implementation",
5
5
  "main": "src/index.js",
6
6
  "repository": {
@@ -30,7 +30,7 @@
30
30
  },
31
31
  "homepage": "https://github.com/zerodensity/realityhub-api#readme",
32
32
  "dependencies": {
33
- "uuid": "^8.3.1",
34
- "ws": "^7.4.6"
33
+ "uuid": "^11.0.3",
34
+ "ws": "^8.18.0"
35
35
  }
36
36
  }
@@ -62,6 +62,7 @@ module.exports = class BrokerClient extends BrokerBase {
62
62
 
63
63
  this.isDuplicate = params.isDuplicate;
64
64
  this.parent = params.parent;
65
+ this.ssl = params.ssl;
65
66
  this.duplicates = new Set();
66
67
 
67
68
  // moduleName of the server (will be set when we receive a ping message)
@@ -125,13 +126,23 @@ module.exports = class BrokerClient extends BrokerBase {
125
126
  url = { hostname: options.host, port: options.port };
126
127
  }
127
128
 
128
- const scheme = url.protocol === 'https:' ? 'wss' : 'ws';
129
+ const scheme = (url.protocol === 'https:' || this.ssl) ? 'wss' : 'ws';
129
130
 
130
131
  const webSocketURL = url.port
131
132
  ? `${scheme}://${url.hostname}:${url.port}${this.webSocketURL}`
132
133
  : `${scheme}://${url.hostname}${this.webSocketURL}`;
133
134
 
134
- this.socket = new ws(webSocketURL);
135
+ this.logger.info(`BrokerClient is connecting to ${webSocketURL}`);
136
+
137
+ if (typeof process !== "undefined" && process.versions != null && process.versions.node != null) {
138
+ const NODE_TLS_REJECT_UNAUTHORIZED = process.env.NODE_TLS_REJECT_UNAUTHORIZED;
139
+ process.env.NODE_TLS_REJECT_UNAUTHORIZED = 0;
140
+ this.socket = new ws(webSocketURL);
141
+ process.env.NODE_TLS_REJECT_UNAUTHORIZED = NODE_TLS_REJECT_UNAUTHORIZED;
142
+ } else {
143
+ this.socket = new ws(webSocketURL);
144
+ }
145
+
135
146
  this.addSocketListeners();
136
147
  }
137
148