summary refs log tree commit diff
path: root/src/webrtc/opcodes
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2026-08-15 17:09:40 +0200
committerRory& <root@rory.gay>2026-08-15 17:15:40 +0200
commit9f5f2a2c3b71550f21f75500534bf1332b94f771 (patch)
tree4572ef19b7e25fee06da36a62105b197cb45fade /src/webrtc/opcodes
parentAllow avatar_description field in profile update (diff)
downloadserver-ts-github/dev/gwsep.tar.xz
Decouple gateway connection state from inner ws object github/dev/gwsep dev/gwsep
Diffstat (limited to 'src/webrtc/opcodes')
-rw-r--r--src/webrtc/opcodes/Heartbeat.ts2
-rw-r--r--src/webrtc/opcodes/Identify.ts8
-rw-r--r--src/webrtc/opcodes/SelectProtocol.ts3
3 files changed, 7 insertions, 6 deletions
diff --git a/src/webrtc/opcodes/Heartbeat.ts b/src/webrtc/opcodes/Heartbeat.ts

index ee0e72b3..8e38a11a 100644 --- a/src/webrtc/opcodes/Heartbeat.ts +++ b/src/webrtc/opcodes/Heartbeat.ts
@@ -21,7 +21,7 @@ import { VoiceOPCodes, VoicePayload, WebRtcWebSocket, Send } from "../util"; export async function onHeartbeat(this: WebRtcWebSocket, data: VoicePayload) { setHeartbeat(this); - if (isNaN(data.d)) return this.close(CLOSECODES.Decode_error); + if (isNaN(data.d)) return this.rawSocket.close(CLOSECODES.Decode_error); await Send(this, { op: VoiceOPCodes.HEARTBEAT_ACK, d: data.d }); } diff --git a/src/webrtc/opcodes/Identify.ts b/src/webrtc/opcodes/Identify.ts
index 7d776d9c..fdf5f449 100644 --- a/src/webrtc/opcodes/Identify.ts +++ b/src/webrtc/opcodes/Identify.ts
@@ -64,14 +64,14 @@ export async function onIdentify(this: WebRtcWebSocket, data: VoicePayload) { streamSession.used = true; await streamSession.save(); - this.once("close", async () => { + this.rawSocket.once("close", async () => { await streamSession.remove(); }); } } // if it doesnt match any then not valid token - if (!authenticated) return this.close(CLOSECODES.Authentication_failed); + if (!authenticated) return this.rawSocket.close(CLOSECODES.Authentication_failed); this.user_id = user_id; this.session_id = session_id; @@ -82,10 +82,10 @@ export async function onIdentify(this: WebRtcWebSocket, data: VoicePayload) { try { this.webRtcClient = await mediaServer.join(voiceRoomId, this.user_id, this, type!); } catch (e) { - return this.close(4013); + return this.rawSocket.close(4013); } - this.on("close", () => { + this.rawSocket.on("close", () => { // ice-lite media server relies on this to know when the peer went away mediaServer.onClientClose(this.webRtcClient!); }); diff --git a/src/webrtc/opcodes/SelectProtocol.ts b/src/webrtc/opcodes/SelectProtocol.ts
index 6a733932..c3b61554 100644 --- a/src/webrtc/opcodes/SelectProtocol.ts +++ b/src/webrtc/opcodes/SelectProtocol.ts
@@ -15,6 +15,7 @@ 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 { SelectProtocolSchema, validateSchema } from "@spacebar/schemas"; import { VoiceOPCodes, VoicePayload, WebRtcWebSocket, mediaServer, Send } from "@spacebar/webrtc"; @@ -24,7 +25,7 @@ export async function onSelectProtocol(this: WebRtcWebSocket, payload: VoicePayl const data = validateSchema("SelectProtocolSchema", payload.d) as SelectProtocolSchema; // UDP protocol not currently supported. Maybe in the future? - if (data.protocol !== "webrtc") return this.close(4000, "only webrtc protocol supported currently"); + if (data.protocol !== "webrtc") return this.rawSocket.close(4000, "only webrtc protocol supported currently"); const response = await mediaServer.onOffer(this.webRtcClient, data.sdp!, data.codecs ?? []);