mirror of
https://github.com/wisplite/tether.git
synced 2026-05-01 06:22:41 -05:00
update logging and add testing to make sure client IDs are stable
This commit is contained in:
@@ -41,19 +41,19 @@ func (e *Engine) Handle(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (e *Engine) OnConnect(clientID string) error {
|
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
|
// TODO: implement the logic to handle the connection
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Engine) OnDisconnect(clientID string) error {
|
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
|
// TODO: implement the logic to handle the disconnection
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Engine) OnReceiveMessage(clientID string, msg map[string]interface{}) error {
|
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
|
// TODO: implement the logic to handle the message
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,12 @@ function test() {
|
|||||||
type: "subscribe",
|
type: "subscribe",
|
||||||
channel: "messages",
|
channel: "messages",
|
||||||
}));
|
}));
|
||||||
|
setTimeout(() => {
|
||||||
|
ws.send(JSON.stringify({
|
||||||
|
type: "unsubscribe",
|
||||||
|
channel: "messages",
|
||||||
|
}));
|
||||||
|
}, 5000);
|
||||||
};
|
};
|
||||||
ws.onclose = () => {
|
ws.onclose = () => {
|
||||||
console.log("Disconnected from server");
|
console.log("Disconnected from server");
|
||||||
|
|||||||
Reference in New Issue
Block a user