0.0.120
This commit is contained in:
@@ -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")
|
||||
//
|
||||
|
||||
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user