From 3cff324d9dc177e7098f5859f2d9c11878671b99 Mon Sep 17 00:00:00 2001 From: wisplite Date: Wed, 8 Apr 2026 12:27:16 -0500 Subject: [PATCH] update logging and add testing to make sure client IDs are stable --- engine.go | 6 +++--- example/client/test.ts | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/engine.go b/engine.go index 0d7cb6f..22a14b5 100644 --- a/engine.go +++ b/engine.go @@ -41,19 +41,19 @@ func (e *Engine) Handle(w http.ResponseWriter, r *http.Request) { } func (e *Engine) OnConnect(clientID string) error { - slog.Debug("Connected to websocket") + slog.Debug("Connected to websocket", "client", clientID) // TODO: implement the logic to handle the connection return nil } func (e *Engine) OnDisconnect(clientID string) error { - slog.Debug("Disconnected from websocket") + slog.Debug("Disconnected from websocket", "client", clientID) // TODO: implement the logic to handle the disconnection return nil } func (e *Engine) OnReceiveMessage(clientID string, msg map[string]interface{}) error { - slog.Debug("Received message", "message", msg) + slog.Debug("Received message", "from", clientID, "message", msg) // TODO: implement the logic to handle the message return nil } diff --git a/example/client/test.ts b/example/client/test.ts index a18c30f..50afe6a 100644 --- a/example/client/test.ts +++ b/example/client/test.ts @@ -9,6 +9,12 @@ function test() { type: "subscribe", channel: "messages", })); + setTimeout(() => { + ws.send(JSON.stringify({ + type: "unsubscribe", + channel: "messages", + })); + }, 5000); }; ws.onclose = () => { console.log("Disconnected from server");