dbm-graph-api 1.0.3 → 1.0.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dbm-graph-api",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -13,7 +13,10 @@
13
13
  "dependencies": {
14
14
  "@aws-sdk/client-s3": "^3.693.0",
15
15
  "@aws-sdk/s3-request-presigner": "^3.693.0",
16
- "dbm": "^1.0.3",
16
+ "dbm": "^1.0.4",
17
17
  "ws": "^8.18.0"
18
+ },
19
+ "optionalDependencies": {
20
+ "bufferutil": "^4.0.8"
18
21
  }
19
22
  }
@@ -49,7 +49,7 @@ export default class Api extends Dbm.core.BaseObject {
49
49
  let user = Dbm.getInstance().repository.getItem("graphDatabase").controller.getUser(userId);
50
50
 
51
51
  user.verifySession(value).then(function(aIsValidSession) {
52
- console.log("verifySession", aIsValidSession);
52
+ //console.log("verifySession", aIsValidSession);
53
53
 
54
54
  if(aIsValidSession) {
55
55
  newWebSocketConnection.setInitialUser(userId);
@@ -69,4 +69,15 @@ export default class Api extends Dbm.core.BaseObject {
69
69
  newWebSocketConnection.setInitialUser(0);
70
70
  }
71
71
  }
72
+
73
+ connectionClosed(aConnection) {
74
+ //console.log("connectionClosed");
75
+ let connections = [].concat(this.item.connections);
76
+ let index = connections.indexOf(aConnection.item);
77
+ if(index >= 0) {
78
+ connections.splice(index, 1);
79
+ }
80
+
81
+ this.item.setValue("connections", connections);
82
+ }
72
83
  }
@@ -42,7 +42,7 @@ export default class UrlRequest extends Dbm.core.BaseObject {
42
42
  }
43
43
 
44
44
  outputEncodedData(aId, aData, aEncoding) {
45
- console.log("UrlRequest::outputEncodedData");
45
+ //console.log("UrlRequest::outputEncodedData");
46
46
 
47
47
  this._encodedObjects.push({"id": aId, "data": aData, "encoding": aEncoding});
48
48
 
@@ -8,6 +8,7 @@ export default class WebSocketConnection extends Dbm.core.BaseObject {
8
8
 
9
9
  this._callback_errorBound = this._callback_error.bind(this);
10
10
  this._callback_messageBound = this._callback_message.bind(this);
11
+ this._callback_closeBound = this._callback_close.bind(this);
11
12
  }
12
13
 
13
14
  setWebSocket(aWebSocket) {
@@ -32,7 +33,7 @@ export default class WebSocketConnection extends Dbm.core.BaseObject {
32
33
  }
33
34
 
34
35
  async _callback_message(aDataString) {
35
- console.log('received: %s', aDataString);
36
+ //console.log('received: %s', aDataString);
36
37
 
37
38
  let data;
38
39
 
@@ -225,25 +226,52 @@ export default class WebSocketConnection extends Dbm.core.BaseObject {
225
226
 
226
227
  this._webSocket.send(JSON.stringify({"type": "currentUser/response", "id": userId, "requestId": data["requestId"]}));
227
228
 
229
+ }
230
+ break;
231
+ case "heartbeat":
232
+ {
233
+ this._webSocket.send(JSON.stringify({"type": "heartbeat/response"}));
234
+
228
235
  }
229
236
  break;
230
237
  }
231
238
  }
232
239
 
233
240
  _callback_error(aMessage) {
241
+ console.log("_callback_error");
234
242
  console.error(aMessage);
235
243
  }
244
+
245
+ _callback_close() {
246
+ //console.log("_callback_close");
247
+
248
+ if(this._webSocket) {
249
+ this._webSocket.off('error', this._callback_error);
250
+ this._webSocket.off('message', this._callback_messageBound);
251
+ this._webSocket.off('close', this._callback_closeBound);
252
+ this._webSocket = null;
253
+ }
254
+
255
+ this._callback_errorBound = null;
256
+ this._callback_messageBound = null;
257
+ this._callback_closeBound = null;
258
+
259
+ this.item.api.controller.connectionClosed(this);
260
+ this.item.setValue("api", null);
261
+ this.item.setValue("controller", null);
262
+ }
236
263
 
237
264
  addListeners() {
238
265
 
239
266
  this._webSocket.on('error', this._callback_error);
240
267
  this._webSocket.on('message', this._callback_messageBound);
268
+ this._webSocket.on('close', this._callback_closeBound);
241
269
 
242
270
  return this;
243
271
  }
244
272
 
245
273
  outputEncodedData(aId, aData, aEncoding) {
246
- console.log("WebSocketConnection::outputEncodedData");
274
+ //console.log("WebSocketConnection::outputEncodedData");
247
275
 
248
276
  this._webSocket.send(JSON.stringify({"type": "updateEncodedObject", "id": aId, "data": aData, "encoding": aEncoding}));
249
277