diff --git a/static/js/chat_sockets.js b/static/js/chat_sockets.js index 0dd05dc..021bd4c 100644 --- a/static/js/chat_sockets.js +++ b/static/js/chat_sockets.js @@ -1,4 +1,4 @@ -chatSocket = new WebSocket(ws_url); + function sendMessageSocket (data) { chatSocket.send(JSON.stringify(data)); diff --git a/templates/tb_base.html b/templates/tb_base.html index 5d6c73a..cf32ccf 100644 --- a/templates/tb_base.html +++ b/templates/tb_base.html @@ -13,7 +13,7 @@ {#var user_id = {{ user.id }}#} ws_url = `ws://{% get_ws_address %}/ws/socket-server/?user_id={{ user.id }}`; - + const chatSocket = new WebSocket(ws_url);