From 8adbd5b4a2977afb4f0dd61c88e60092748054d1 Mon Sep 17 00:00:00 2001 From: a-wing <1@233.email> Date: Fri, 14 Jul 2023 18:40:10 +0800 Subject: [PATCH] feat(cmd): add log --- cmd/lightcable/main.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/cmd/lightcable/main.go b/cmd/lightcable/main.go index 7b07050..7ddbec7 100644 --- a/cmd/lightcable/main.go +++ b/cmd/lightcable/main.go @@ -20,6 +20,21 @@ func main() { } server := lightcable.New(lightcable.DefaultConfig) + server.OnRoomReady(func(room string) { + log.Printf("Room Ready: %s", room) + }) + server.OnRoomClose(func(room string) { + log.Printf("Room Close: %s", room) + }) + server.OnConnReady(func(c *lightcable.Client) { + log.Printf("Room: %s, Conn Ready: %s", c.Room, c.Name) + }) + server.OnConnClose(func(c *lightcable.Client) { + log.Printf("Room: %s, Conn Close: %s", c.Room, c.Name) + }) + server.OnMessage(func(m *lightcable.Message) { + log.Printf("Room: %s, Conn: %s, Data: %s, Code: %d", m.Room, m.Name, m.Data, m.Code) + }) go server.Run(context.Background()) log.Println("Listen address:", *address)