diff --git a/cursor/cursor.go b/cursor/cursor.go index 4e4504f..4ed59e3 100644 --- a/cursor/cursor.go +++ b/cursor/cursor.go @@ -88,13 +88,13 @@ func handleClient(client *CursorClient) { client.Route = args[1] mutex.Lock() - for _, otherClient := range clients { - if otherClient.ID == client.ID { continue } - if otherClient.Route != client.Route { continue } - client.Send([]byte(fmt.Sprintf("join:%d", otherClient.ID))) - client.Send([]byte(fmt.Sprintf("pos:%d:%f:%f", otherClient.ID, otherClient.X, otherClient.Y))) + for otherClientID, otherClient := range clients { + if otherClientID == client.ID || otherClient.Route != client.Route { continue } + client.Send([]byte(fmt.Sprintf("join:%d", otherClientID))) + client.Send([]byte(fmt.Sprintf("pos:%d:%f:%f", otherClientID, otherClient.X, otherClient.Y))) } mutex.Unlock() + broadcast <- CursorMessage{ []byte(fmt.Sprintf("join:%d", client.ID)), client.Route, diff --git a/public/script/config.js b/public/script/config.js index 1ab8b5a..402a74b 100644 --- a/public/script/config.js +++ b/public/script/config.js @@ -55,6 +55,7 @@ class Config { get crt() { return this._crt } set crt(/** @type boolean */ enabled) { this._crt = enabled; + this.save(); if (enabled) { document.body.classList.add("crt"); @@ -66,26 +67,24 @@ class Config { this.#listeners.get('crt').forEach(callback => { callback(this._crt); }) - - this.save(); } get cursor() { return this._cursor } set cursor(/** @type boolean */ value) { this._cursor = value; + this.save(); this.#listeners.get('cursor').forEach(callback => { callback(this._cursor); }) - this.save(); } get cursorFunMode() { return this._cursorFunMode } set cursorFunMode(/** @type boolean */ value) { this._cursorFunMode = value; + this.save(); this.#listeners.get('cursorFunMode').forEach(callback => { callback(this._cursorFunMode); }) - this.save(); } } diff --git a/public/script/cursor.js b/public/script/cursor.js index 188cdbb..79637fe 100644 --- a/public/script/cursor.js +++ b/public/script/cursor.js @@ -328,7 +328,7 @@ function cursorSetup() { switch (args[0]) { case 'id': { - myCursor.id = Number(args[1]); + myCursor.id = id; break; } case 'join': { @@ -385,8 +385,6 @@ function cursorDestroy() { cursors.clear(); myCursor = null; - cursorContainer.remove(); - console.log(`Cursor no longer tracking.`); running = false; }