fix: 解决json无法正常解析的问题
This commit is contained in:
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user