fixed API and stopping delay
This commit is contained in:
@@ -21,7 +21,15 @@ export function connectWs(onMessage, opts = {}) {
|
||||
}
|
||||
open();
|
||||
return {
|
||||
send(msg) { if (ws?.readyState === WebSocket.OPEN) ws.send(JSON.stringify(msg)); },
|
||||
// Returns true when the message was actually queued on a live socket,
|
||||
// false when the socket is closing/reconnecting. Callers that need to
|
||||
// surface a transport failure (transport buttons) inspect the result;
|
||||
// fire-and-forget callers can ignore it.
|
||||
send(msg) {
|
||||
if (ws?.readyState !== WebSocket.OPEN) return false;
|
||||
ws.send(JSON.stringify(msg));
|
||||
return true;
|
||||
},
|
||||
close() { closed = true; ws?.close(); },
|
||||
get readyState() { return ws?.readyState; }
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user