relay: only send if socket is open
This commit is contained in:
parent
f7cd67c572
commit
b60e84d29b
|
@ -1,5 +1,4 @@
|
||||||
import { AppController } from '@/app.ts';
|
import { AppController } from '@/app.ts';
|
||||||
import { type Event } from '@/deps.ts';
|
|
||||||
import { type DittoFilter } from '@/filter.ts';
|
import { type DittoFilter } from '@/filter.ts';
|
||||||
import { TOKEN_REGEX } from '@/middleware/auth19.ts';
|
import { TOKEN_REGEX } from '@/middleware/auth19.ts';
|
||||||
import { streamSchema, ws } from '@/stream.ts';
|
import { streamSchema, ws } from '@/stream.ts';
|
||||||
|
|
|
@ -90,7 +90,9 @@ function connectStream(socket: WebSocket) {
|
||||||
|
|
||||||
/** Send a message back to the client. */
|
/** Send a message back to the client. */
|
||||||
function send(msg: RelayMsg): void {
|
function send(msg: RelayMsg): void {
|
||||||
return socket.send(JSON.stringify(msg));
|
if (socket.readyState === WebSocket.OPEN) {
|
||||||
|
socket.send(JSON.stringify(msg));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue