diff --git a/wshandler/room.go b/wshandler/room.go index 786793d..c26bbf0 100644 --- a/wshandler/room.go +++ b/wshandler/room.go @@ -1,6 +1,7 @@ package wshandler import ( + "bytes" "context" "encoding/json" @@ -84,13 +85,17 @@ func (r *room) loop(ctx context.Context, conns *map[string]*wsconn) (normalEnd b Body: msg.Body, Tag: append(msg.Tag, tag), } - bt, _ := json.Marshal(ds) + + buff := new(bytes.Buffer) + enc := json.NewEncoder(buff) + enc.SetEscapeHTML(false) + enc.Encode(ds) for _, conn := range *conns { r.sendMsgChan <- send_msg_queue_elem{ to: conn, mt: websocket.TextMessage, - msg: bt, + msg: buff.Bytes(), } } }