diff --git a/assets/js/common/ws.js b/assets/js/common/ws.js index 3595d642..4288cb81 100644 --- a/assets/js/common/ws.js +++ b/assets/js/common/ws.js @@ -29,6 +29,11 @@ class UserWebSocket { this.ws.addEventListener("error", (e) => this.Error(e)) this.ws.addEventListener("close", (e) => this.Closed(e)); + // Handle incoming messages + this.ws.addEventListener("message", (e) => { + this.ProcessMessage(JSON.parse(e.data)); + }) + } catch(e) { this.Error(e); } @@ -74,4 +79,13 @@ class UserWebSocket { delete this.ws } } + + /** + * Process an incoming message + * + * @param {any} msg The incoming message + */ + static async ProcessMessage(msg) { + console.error("WS message", msg) + } } \ No newline at end of file