@nora-link/client 1.0.14 → 1.0.15

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/dist/client.d.ts CHANGED
@@ -19,7 +19,7 @@ export declare class Client {
19
19
  constructor(options: ClientConnectionOptions);
20
20
  private server$;
21
21
  private data$;
22
- readonly handle$: Observable<'connected' | 'connecting'>;
22
+ readonly handle$: Observable<'connected' | 'connecting' | 'disconnected'>;
23
23
  private send;
24
24
  private getStreamData;
25
25
  private httpRequest;
package/dist/client.js CHANGED
@@ -42,12 +42,19 @@ class Client {
42
42
  const handler = (msg) => {
43
43
  Buffer.isBuffer(msg) && observer.next(msg);
44
44
  };
45
- ws.on('message', handler);
46
- ws.once('error', err => observer.error(err));
47
- ws.once('close', (code, reason) => {
45
+ const errorHandler = (err) => observer.error(err);
46
+ const closeHandler = (code, reason) => {
48
47
  observer.error(new Error(`${code} - ${reason.toString()}`));
49
- });
50
- return () => ws.off('message', handler);
48
+ };
49
+ ws.on('message', handler);
50
+ ws.once('error', errorHandler);
51
+ ws.once('close', closeHandler);
52
+ return () => {
53
+ ws.off('message', handler);
54
+ ws.off('error', errorHandler);
55
+ ws.off('close', closeHandler);
56
+ ws.close();
57
+ };
51
58
  })), (0, rxjs_1.map)(v => {
52
59
  if (v.length >= 5) {
53
60
  const id = v.readUint32BE();
@@ -68,7 +75,7 @@ class Client {
68
75
  data$: this.getStreamData(id),
69
76
  send: (type, msg) => this.send(id, type, msg),
70
77
  })
71
- : rxjs_1.EMPTY))).pipe((0, rxjs_1.startWith)('connecting'), (0, rxjs_1.map)(_ => 'connected'), (0, rxjs_1.retry)({
78
+ : rxjs_1.EMPTY))).pipe((0, rxjs_1.startWith)('connecting'), (0, rxjs_1.map)(_ => 'connected'), (0, rxjs_1.catchError)(err => (0, rxjs_1.concat)((0, rxjs_1.of)('disconnected'), (0, rxjs_1.throwError)(() => err))), (0, rxjs_1.retry)({
72
79
  resetOnSuccess: true,
73
80
  delay: (err, retryCount) => {
74
81
  const delaySeconds = Math.round(Math.min(600, Math.pow(1.8, retryCount - 1)));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nora-link/client",
3
- "version": "1.0.14",
3
+ "version": "1.0.15",
4
4
  "description": "noralink.eu client",
5
5
  "bin": {
6
6
  "noralink": "dist/cli.js"