node-red-contrib-mobius-flow-base 3.4.0-beta.1 → 3.5.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.
@@ -1,5 +1,5 @@
1
- import { EventEmitter } from 'stream';
2
- type WebSocketTopics = 'authorize' | 'subscribe' | 'unsubscribe' | 'connected' | 'authorized' | 'object-cov' | 'resource-cov' | 'service-status' | 'broadcast-command' | 'error' | 'ping' | 'pong';
1
+ import { EventEmitter } from "stream";
2
+ type WebSocketTopics = "authorize" | "subscribe" | "unsubscribe" | "connected" | "authorized" | "object-cov" | "resource-cov" | "service-status" | "broadcast-command" | "error" | "ping" | "pong";
3
3
  interface EngineWebSocketInterface {
4
4
  registerCallback: (topic: WebSocketTopics, callback: Function) => void;
5
5
  clearAllCallbacks: () => void;
@@ -24,7 +24,7 @@ export declare class EngineWebSocket extends EventEmitter implements EngineWebSo
24
24
  private authToken;
25
25
  private hostname;
26
26
  private protocol;
27
- constructor(hostname: string, protocol: 'http' | 'https');
27
+ constructor(hostname: string, protocol: "http" | "https");
28
28
  connectToWebSocket: (token: string) => void;
29
29
  private sendWebSocketMessage;
30
30
  private sendPingMessage;
@@ -24,18 +24,18 @@ class EngineWebSocket extends stream_1.EventEmitter {
24
24
  }
25
25
  connectToWebSocket = (token) => {
26
26
  this.authToken = token;
27
- let webSocketProtocol = 'wss';
28
- if (this.protocol === 'http') {
29
- webSocketProtocol = 'ws';
27
+ let webSocketProtocol = "wss";
28
+ if (this.protocol === "http") {
29
+ webSocketProtocol = "ws";
30
30
  }
31
- this.webSocket = new ws_1.default(`${webSocketProtocol}://${this.hostname}/api/v1/mobius/subscribe/connect`);
31
+ this.webSocket = new ws_1.default(`${webSocketProtocol}://${this.hostname}/api/engine/v1/mobius/subscribe/connect`);
32
32
  this.webSocket.onopen = () => {
33
33
  this.attemptReconnect = true;
34
34
  console.log(`(${this.hostname}) -> Engine API Subscription WebSocket Client Connected`);
35
35
  this.pingInterval = setInterval(this.sendPingMessage, 30000);
36
36
  clearInterval(this.reconnectInterval);
37
37
  this.sendWebSocketMessage({
38
- topic: 'authorize',
38
+ topic: "authorize",
39
39
  payload: `Bearer ${this.authToken}`,
40
40
  });
41
41
  this.pendingWebSocketMessageInterval = setInterval(() => {
@@ -60,7 +60,7 @@ class EngineWebSocket extends stream_1.EventEmitter {
60
60
  this.reconnect();
61
61
  }, 30000);
62
62
  }
63
- this.emit('disconnected');
63
+ this.emit("disconnected");
64
64
  };
65
65
  this.webSocket.onmessage = (message) => {
66
66
  try {
@@ -70,15 +70,15 @@ class EngineWebSocket extends stream_1.EventEmitter {
70
70
  }
71
71
  }
72
72
  catch (e) {
73
- console.log(`(${this.hostname}) -> Error parsing message: ${e.code}, ${e.message ? e.message : ''}`);
73
+ console.log(`(${this.hostname}) -> Error parsing message: ${e.code}, ${e.message ? e.message : ""}`);
74
74
  }
75
75
  };
76
- this.webSocket.on('error', (e) => {
77
- if (e.code === 'ECONNREFUSED') {
78
- this.emit('disconnected');
76
+ this.webSocket.on("error", (e) => {
77
+ if (e.code === "ECONNREFUSED") {
78
+ this.emit("disconnected");
79
79
  }
80
80
  else {
81
- console.error(`(${this.hostname}) -> Engine API Subscription WebSocket Client Error: ${e.code}, ${e.message ? e.message : ''}`);
81
+ console.error(`(${this.hostname}) -> Engine API Subscription WebSocket Client Error: ${e.code}, ${e.message ? e.message : ""}`);
82
82
  }
83
83
  });
84
84
  };
@@ -97,7 +97,7 @@ class EngineWebSocket extends stream_1.EventEmitter {
97
97
  };
98
98
  sendPingMessage = () => {
99
99
  this.sendWebSocketMessage({
100
- topic: 'ping',
100
+ topic: "ping",
101
101
  payload: {},
102
102
  });
103
103
  };
@@ -108,12 +108,12 @@ class EngineWebSocket extends stream_1.EventEmitter {
108
108
  this.registeredCallbacks = [];
109
109
  };
110
110
  handleWebSocketMessage = (message) => {
111
- if (message.topic === 'error') {
111
+ if (message.topic === "error") {
112
112
  console.log(`(${this.hostname}) -> Websocket Error: ${message.payload}`);
113
113
  }
114
- if (message.topic === 'authorized') {
114
+ if (message.topic === "authorized") {
115
115
  console.log(`(${this.hostname}) -> Engine API Subscription WebSocket Auth Success`);
116
- this.emit('connected');
116
+ this.emit("connected");
117
117
  }
118
118
  const callbacks = this.registeredCallbacks
119
119
  .filter((cb) => cb.topic === message.topic)
@@ -153,38 +153,38 @@ class EngineWebSocket extends stream_1.EventEmitter {
153
153
  };
154
154
  subscribeToObjectCOV = (uri) => {
155
155
  this.sendWebSocketMessage({
156
- topic: 'subscribe',
157
- payload: { type: 'object-cov', uri },
156
+ topic: "subscribe",
157
+ payload: { type: "object-cov", uri },
158
158
  });
159
159
  };
160
160
  unsubscribeToObjectCOV = (uri) => {
161
161
  this.sendWebSocketMessage({
162
- topic: 'unsubscribe',
163
- payload: { type: 'object-cov', uri },
162
+ topic: "unsubscribe",
163
+ payload: { type: "object-cov", uri },
164
164
  });
165
165
  };
166
166
  subscribeToResourceCOV = (uri) => {
167
167
  this.sendWebSocketMessage({
168
- topic: 'subscribe',
169
- payload: { type: 'resource-cov', uri },
168
+ topic: "subscribe",
169
+ payload: { type: "resource-cov", uri },
170
170
  });
171
171
  };
172
172
  unsubscribeToResourceCOV = (uri) => {
173
173
  this.sendWebSocketMessage({
174
- topic: 'unsubscribe',
175
- payload: { type: 'resource-cov', uri },
174
+ topic: "unsubscribe",
175
+ payload: { type: "resource-cov", uri },
176
176
  });
177
177
  };
178
178
  subscribeToBCMD = (uri) => {
179
179
  this.sendWebSocketMessage({
180
- topic: 'subscribe',
181
- payload: { type: 'broadcast-command', uri },
180
+ topic: "subscribe",
181
+ payload: { type: "broadcast-command", uri },
182
182
  });
183
183
  };
184
184
  unsubscribeToBCMD = (uri) => {
185
185
  this.sendWebSocketMessage({
186
- topic: 'unsubscribe',
187
- payload: { type: 'broadcast-command', uri },
186
+ topic: "unsubscribe",
187
+ payload: { type: "broadcast-command", uri },
188
188
  });
189
189
  };
190
190
  }
@@ -30,7 +30,7 @@ POSSIBILITY OF SUCH DAMAGE.
30
30
  <input class="input-append-left" type="text" id="node-config-input-host" placeholder="e.g. localhost" style="width: 70%;" >
31
31
  </div>
32
32
  <p style="text-align:center"> Ensure port number is included in host path if required</p>
33
- <p style="text-align:center"> e.g. <b>myHostname:8443</b></p>
33
+ <p style="text-align:center"> e.g. <b>myHostname:8442</b></p>
34
34
  <hr>
35
35
  <div class="form-row">
36
36
  <label for="node-config-input-username"><i class="fa fa-user"></i> Username</label>
@@ -49,25 +49,25 @@ POSSIBILITY OF SUCH DAMAGE.
49
49
  </script>
50
50
 
51
51
  <script type="text/javascript">
52
- hostLabel = 'test';
53
- RED.nodes.registerType('mobius connection', {
54
- category: 'config',
52
+ hostLabel = "test";
53
+ RED.nodes.registerType("mobius connection", {
54
+ category: "config",
55
55
  defaults: {
56
- host: { required: true, value: 'mobius:8443' },
57
- username: { required: true, value: '' },
58
- password: { required: true, value: '' },
56
+ host: { required: true, value: "mobius:8442" },
57
+ username: { required: true, value: "" },
58
+ password: { required: true, value: "" },
59
59
  secure: { required: true, value: false },
60
60
  },
61
61
  label: function () {
62
62
  return `${this.host}`;
63
63
  },
64
64
  oneditprepare: function () {
65
- $('#node-config-input-secure').change(function () {
66
- let secure = $('#node-config-input-secure').is(':checked');
65
+ $("#node-config-input-secure").change(function () {
66
+ let secure = $("#node-config-input-secure").is(":checked");
67
67
  if (secure) {
68
- document.getElementById('hostLabel').innerHTML = 'https://';
68
+ document.getElementById("hostLabel").innerHTML = "https://";
69
69
  } else {
70
- document.getElementById('hostLabel').innerHTML = 'http://';
70
+ document.getElementById("hostLabel").innerHTML = "http://";
71
71
  }
72
72
  });
73
73
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-mobius-flow-base",
3
- "version": "3.4.0-beta.1",
3
+ "version": "3.5.0",
4
4
  "description": "Node-RED base nodes for Mobius Flow",
5
5
  "main": "index.js",
6
6
  "types": "dist/index.d.ts",