This commit is contained in:
2023-08-12 14:37:27 +03:00
parent f5c709eb7b
commit 437ee3066f

View File

@@ -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")
//
// }
}