@cocreate/socket-server 1.35.0 → 1.35.1
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 +1 -1
- package/src/index.js +3 -3
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
// For details, visit <https://cocreate.app/licenses/> or contact us at sales@cocreate.app.
|
|
22
22
|
|
|
23
23
|
import { EventEmitter } from 'node:events';
|
|
24
|
-
import { WebSocketServer } from 'ws';
|
|
24
|
+
import { WebSocket, WebSocketServer } from 'ws';
|
|
25
25
|
import { URL } from 'node:url';
|
|
26
26
|
import { uuid } from '@cocreate/utils';
|
|
27
27
|
import Config from '@cocreate/config';
|
|
@@ -79,7 +79,7 @@ export class SocketServer extends EventEmitter {
|
|
|
79
79
|
}
|
|
80
80
|
socket.isAlive = false;
|
|
81
81
|
try {
|
|
82
|
-
if (socket.readyState ===
|
|
82
|
+
if (socket.readyState === WebSocket.OPEN) {
|
|
83
83
|
socket.ping();
|
|
84
84
|
} else {
|
|
85
85
|
socket.terminate();
|
|
@@ -826,7 +826,7 @@ export class SocketServer extends EventEmitter {
|
|
|
826
826
|
// Helper to send payloads safely on valid connections without throwing frame failures
|
|
827
827
|
_safeSend(socket, payload) {
|
|
828
828
|
try {
|
|
829
|
-
if (socket && socket.readyState ===
|
|
829
|
+
if (socket && socket.readyState === WebSocket.OPEN) {
|
|
830
830
|
const message = typeof payload === "string" ? payload : JSON.stringify(payload);
|
|
831
831
|
socket.send(message);
|
|
832
832
|
}
|