summary refs log tree commit diff
path: root/src/webrtc/util
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2026-08-15 17:09:40 +0200
committerRory& <root@rory.gay>2026-08-18 12:16:45 +0200
commit6b673a2837153edf8995ea482f2ef0ad3f69efde (patch)
tree4203871a916b0c7608dfe58587f6f5ecc9ba2f37 /src/webrtc/util
parentFix logout api (diff)
downloadserver-ts-dev/gwsep.tar.xz
Decouple gateway connection state from inner ws object dev/gwsep
Diffstat (limited to 'src/webrtc/util')
-rw-r--r--src/webrtc/util/Send.ts24
-rw-r--r--src/webrtc/util/WebRtcWebSocket.ts2
2 files changed, 22 insertions, 4 deletions
diff --git a/src/webrtc/util/Send.ts b/src/webrtc/util/Send.ts

index 1d8aa61e4..c3f47bae0 100644 --- a/src/webrtc/util/Send.ts +++ b/src/webrtc/util/Send.ts
@@ -1,3 +1,21 @@ +/* + Spacebar: A FOSS re-implementation and extension of the Discord.com backend. + Copyright (C) 2025 Spacebar and Spacebar Contributors + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <https://www.gnu.org/licenses/>. +*/ + import { JSONReplacer } from "@spacebar/util"; import { VoicePayload } from "./Constants"; import { WebRtcWebSocket } from "./WebRtcWebSocket"; @@ -12,13 +30,13 @@ export function Send(socket: WebRtcWebSocket, data: VoicePayload) { else return; return new Promise((res, rej) => { - if (socket.readyState !== 1) { + if (socket.rawSocket.readyState !== 1) { // return rej("socket not open"); - socket.close(); + socket.rawSocket.close(); return; } - socket.send(buffer, (err) => { + socket.rawSocket.send(buffer, (err) => { if (err) return rej(err); return res(null); }); diff --git a/src/webrtc/util/WebRtcWebSocket.ts b/src/webrtc/util/WebRtcWebSocket.ts
index e36b4f1dc..8d07dfdfb 100644 --- a/src/webrtc/util/WebRtcWebSocket.ts +++ b/src/webrtc/util/WebRtcWebSocket.ts
@@ -1,7 +1,7 @@ import { WebSocket } from "@spacebar/gateway"; import type { WebRtcClient } from "@spacebarchat/spacebar-webrtc-types"; -export interface WebRtcWebSocket extends WebSocket { +export class WebRtcWebSocket extends WebSocket { type: "guild-voice" | "dm-voice" | "stream"; webRtcClient?: WebRtcClient<WebRtcWebSocket>; }