camstreamerlib 2.0.5 → 2.0.6
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/CamOverlayDrawingAPI.js +3 -2
- package/WsClient.js +6 -5
- package/package.json +1 -1
package/CamOverlayDrawingAPI.js
CHANGED
|
@@ -40,7 +40,6 @@ class CamOverlayDrawingAPI extends EventEmitter {
|
|
|
40
40
|
this.emit('open');
|
|
41
41
|
}
|
|
42
42
|
catch (err) {
|
|
43
|
-
this.reportError(err);
|
|
44
43
|
}
|
|
45
44
|
});
|
|
46
45
|
}
|
|
@@ -173,7 +172,9 @@ class CamOverlayDrawingAPI extends EventEmitter {
|
|
|
173
172
|
this.emit('message', msg);
|
|
174
173
|
}
|
|
175
174
|
reportError(err) {
|
|
176
|
-
this.ws
|
|
175
|
+
if (this.ws !== undefined) {
|
|
176
|
+
this.ws.close();
|
|
177
|
+
}
|
|
177
178
|
this.emit('error', err);
|
|
178
179
|
}
|
|
179
180
|
reportClose() {
|
package/WsClient.js
CHANGED
|
@@ -69,14 +69,14 @@ class WsClient extends EventEmitter {
|
|
|
69
69
|
this.open(res.headers['www-authenticate']);
|
|
70
70
|
}
|
|
71
71
|
else {
|
|
72
|
-
const e = new Error('
|
|
72
|
+
const e = new Error('Status code: ' + res.statusCode);
|
|
73
73
|
this.emit('error', e);
|
|
74
74
|
}
|
|
75
75
|
}));
|
|
76
76
|
this.ws.on('open', () => this.emit('open'));
|
|
77
77
|
this.ws.on('message', (data) => this.emit('message', data));
|
|
78
78
|
this.ws.on('error', (error) => this.emit('error', error));
|
|
79
|
-
this.ws.on('close', () => this.
|
|
79
|
+
this.ws.on('close', () => this.handleCloseEvent());
|
|
80
80
|
}
|
|
81
81
|
send(data) {
|
|
82
82
|
if (this.ws.readyState === this.ws.OPEN) {
|
|
@@ -86,13 +86,14 @@ class WsClient extends EventEmitter {
|
|
|
86
86
|
close() {
|
|
87
87
|
try {
|
|
88
88
|
this.handleCloseEvent();
|
|
89
|
-
this.ws.
|
|
89
|
+
if (this.ws.readyState !== this.ws.CLOSING && this.ws.readyState !== this.ws.CLOSED) {
|
|
90
|
+
this.ws.close();
|
|
91
|
+
}
|
|
90
92
|
}
|
|
91
93
|
catch (err) {
|
|
92
|
-
this.emit('error', err);
|
|
93
94
|
}
|
|
94
95
|
setTimeout(() => {
|
|
95
|
-
if (this.ws.readyState
|
|
96
|
+
if (this.ws.readyState !== this.ws.CLOSED) {
|
|
96
97
|
this.ws.terminate();
|
|
97
98
|
}
|
|
98
99
|
}, 5000);
|