fix: 解决json无法正常解析的问题

This commit is contained in:
2025-12-17 15:54:26 +08:00
parent 1dbcc03e46
commit 36296b6af4
5 changed files with 25 additions and 22 deletions

View File

@ -57,13 +57,12 @@ func main() {
func ReadBroadCastLoop(ctx context.Context, c *websocket.Conn) {
for {
// var msg protocol.BroadcastMessage
var msg []byte
var msg protocol.BroadcastMessage
if err := wsjson.Read(ctx, c, &msg); err != nil {
log.Println("read broadcast error:", err)
log.Println("Read broadcast error:", err)
return
}
log.Println("Received broadcast message:", string(msg))
log.Printf("Received broadcast message: [%s] %s", msg.Topic, msg.Payload)
}
}