Skip to content

Commit 8adbd5b

Browse files
committed
feat(cmd): add log
1 parent a0dee51 commit 8adbd5b

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

cmd/lightcable/main.go

+15
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,21 @@ func main() {
2020
}
2121

2222
server := lightcable.New(lightcable.DefaultConfig)
23+
server.OnRoomReady(func(room string) {
24+
log.Printf("Room Ready: %s", room)
25+
})
26+
server.OnRoomClose(func(room string) {
27+
log.Printf("Room Close: %s", room)
28+
})
29+
server.OnConnReady(func(c *lightcable.Client) {
30+
log.Printf("Room: %s, Conn Ready: %s", c.Room, c.Name)
31+
})
32+
server.OnConnClose(func(c *lightcable.Client) {
33+
log.Printf("Room: %s, Conn Close: %s", c.Room, c.Name)
34+
})
35+
server.OnMessage(func(m *lightcable.Message) {
36+
log.Printf("Room: %s, Conn: %s, Data: %s, Code: %d", m.Room, m.Name, m.Data, m.Code)
37+
})
2338
go server.Run(context.Background())
2439

2540
log.Println("Listen address:", *address)

0 commit comments

Comments
 (0)