From 2d0761b8932f11b01e241e2db3a8f08250efe878 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Thu, 7 Sep 2023 19:17:49 +0200 Subject: new protocol --- client-web/source/index.ts | 2 +- client-web/source/protocol/mod.ts | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'client-web/source') diff --git a/client-web/source/index.ts b/client-web/source/index.ts index 8ae7e8f..639f0c9 100644 --- a/client-web/source/index.ts +++ b/client-web/source/index.ts @@ -14,7 +14,7 @@ import { SignalingConnection } from "./protocol/mod.ts"; import { Room } from "./room.ts" import { control_bar, info_br } from "./menu.ts"; -export const VERSION = "0.1.14" +export const VERSION = "0.2.0" export interface ClientConfig { appearance?: { diff --git a/client-web/source/protocol/mod.ts b/client-web/source/protocol/mod.ts index a7e1f63..83ee8cb 100644 --- a/client-web/source/protocol/mod.ts +++ b/client-web/source/protocol/mod.ts @@ -10,7 +10,7 @@ import { crypto_encrypt, crypto_seeded_key, crypt_decrypt, crypto_hash } from ". export class SignalingConnection { room!: string websocket!: WebSocket - signaling_id!: string + room_hash!: string key!: CryptoKey my_id?: number // needed for outgoing relay messages @@ -20,9 +20,9 @@ export class SignalingConnection { constructor() { } async connect(room: string): Promise { this.key = await crypto_seeded_key(room) - this.signaling_id = await crypto_hash(room) + this.room_hash = await crypto_hash(room) log("ws", "connecting…") - const ws_url = new URL(`${window.location.protocol.endsWith("s:") ? "wss" : "ws"}://${window.location.host}/signaling/${encodeURIComponent(this.signaling_id)}`) + const ws_url = new URL(`${window.location.protocol.endsWith("s:") ? "wss" : "ws"}://${window.location.host}/signaling`) this.websocket = new WebSocket(ws_url) this.websocket.onerror = () => this.on_error() this.websocket.onclose = () => this.on_close() @@ -44,6 +44,7 @@ export class SignalingConnection { } on_open() { log("ws", "websocket opened"); + this.send_control({ join: { hash: this.room_hash } }) setInterval(() => this.send_control({ ping: null }), 30000) // stupid workaround for nginx disconnecting inactive connections } on_error() { -- cgit v1.2.3-70-g09d2