From 12cbe529deea0642cee6fc050817b76a462a1b06 Mon Sep 17 00:00:00 2001 From: Gabe Kangas Date: Sat, 31 Jul 2021 12:48:42 -0700 Subject: [PATCH] Fix incorrect handling of messages array. Closes #1287 --- core/chat/server.go | 2 +- webroot/js/utils/websocket.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/core/chat/server.go b/core/chat/server.go index d79ca9817..25729b4ca 100644 --- a/core/chat/server.go +++ b/core/chat/server.go @@ -71,7 +71,7 @@ func (s *ChatServer) Addclient(conn *websocket.Conn, user *user.User, accessToke User: user, ipAddress: conn.RemoteAddr().String(), accessToken: accessToken, - send: make(chan []byte, maxMessageSize), + send: make(chan []byte, 256), UserAgent: userAgent, ConnectedAt: time.Now(), } diff --git a/webroot/js/utils/websocket.js b/webroot/js/utils/websocket.js index 5f1675883..5e9de48e3 100644 --- a/webroot/js/utils/websocket.js +++ b/webroot/js/utils/websocket.js @@ -158,9 +158,9 @@ export default class Websocket { var messages = e.data.split('\n'); for (var i = 0; i < messages.length; i++) { try { - var model = JSON.parse(e.data); + var model = JSON.parse(messages[i]); } catch (e) { - // console.log(e, e.data); + console.error(e, e.data); return; }