@eleven-am/pondsocket-client 0.0.29 → 0.0.30
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/browser/client.js +8 -3
- package/node/node.js +9 -2
- package/package.json +1 -1
package/browser/client.js
CHANGED
|
@@ -47,9 +47,14 @@ class PondClient {
|
|
|
47
47
|
this._disconnecting = false;
|
|
48
48
|
const socket = new WebSocket(this._address.toString());
|
|
49
49
|
socket.onmessage = (message) => {
|
|
50
|
-
const
|
|
51
|
-
const
|
|
52
|
-
|
|
50
|
+
const lines = message.data.trim().split('\n');
|
|
51
|
+
for (const line of lines) {
|
|
52
|
+
if (line.trim()) {
|
|
53
|
+
const data = JSON.parse(line);
|
|
54
|
+
const event = pondsocket_common_1.channelEventSchema.parse(data);
|
|
55
|
+
this._broadcaster.publish(event);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
53
58
|
};
|
|
54
59
|
socket.onerror = () => socket.close();
|
|
55
60
|
socket.onclose = () => {
|
package/node/node.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PondClient = void 0;
|
|
4
|
+
const pondsocket_common_1 = require("@eleven-am/pondsocket-common");
|
|
4
5
|
const client_1 = require("../browser/client");
|
|
5
6
|
// eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-require-imports
|
|
6
7
|
const WebSocket = require('websocket').w3cwebsocket;
|
|
@@ -13,8 +14,14 @@ class PondClient extends client_1.PondClient {
|
|
|
13
14
|
const socket = new WebSocket(this._address.toString());
|
|
14
15
|
socket.onopen = () => this._connectionState.publish(true);
|
|
15
16
|
socket.onmessage = (message) => {
|
|
16
|
-
const
|
|
17
|
-
|
|
17
|
+
const lines = message.data.trim().split('\n');
|
|
18
|
+
for (const line of lines) {
|
|
19
|
+
if (line.trim()) {
|
|
20
|
+
const data = JSON.parse(line);
|
|
21
|
+
const event = pondsocket_common_1.channelEventSchema.parse(data);
|
|
22
|
+
this._broadcaster.publish(event);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
18
25
|
};
|
|
19
26
|
socket.onerror = () => socket.close();
|
|
20
27
|
socket.onclose = () => {
|