diff --git a/static/js/chat_sockets.js b/static/js/chat_sockets.js index b711dbd..156b9ac 100644 --- a/static/js/chat_sockets.js +++ b/static/js/chat_sockets.js @@ -21,32 +21,48 @@ let url = `ws://localhost:8000/ws/socket-server/`; +// +// const chatSocket = new WebSocket(url); -const chatSocket = new WebSocket(url); - -chatSocket.onmessage = function (e) { - let data = JSON.parse(e.data) - console.log('Data: ', data) -} +// chatSocket.onmessage = function (e) { +// let data = JSON.parse(e.data) +// console.log('Data: ', data) +// } // chatSocket.onopen = function () { // console.log("open") // } -// function open_socket () { -chatSocket.onopen = function(){ - console.log("open") -} +// // function open_socket () { +// chatSocket.onopen = function(){ +// console.log("open") +// // chatSocket +// } // } -chatSocket.onclose = function () { - console.log("close") -} +// var i = 0 function sendMessageSocket (data) { + let chatSocket = new WebSocket(url); + chatSocket.onopen = function (){ + console.log("open") + chatSocket.send(JSON.stringify(data)) + } + chatSocket.onclose = function () { + console.log("close") + return false + } // + + // } // open_socket() - chatSocket.send(JSON.stringify(data)) + // chatSocket.OPEN + + // chatSocket.onopen = function (){ + // console.log("open") + // + + // } }