0.0.166
This commit is contained in:
@@ -14,7 +14,8 @@ function sendMessageSocket (data) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
chatSocket.onmessage = function (e) {
|
|
||||||
|
function wsReceiveData (e) {
|
||||||
|
|
||||||
let old_item_tab_user_list = inital_old_tab()
|
let old_item_tab_user_list = inital_old_tab()
|
||||||
let el_tab = old_item_tab_user_list[0]
|
let el_tab = old_item_tab_user_list[0]
|
||||||
|
|||||||
@@ -23,18 +23,38 @@ function getNewMessageSession(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
// function getSocketState () {
|
// function getSocketState () {
|
||||||
chatSocket.onclose = function (){
|
|
||||||
console.log("closed")
|
|
||||||
setTimeout(onopen_ws,1000)
|
|
||||||
|
|
||||||
}
|
// function onopen_ws (){
|
||||||
function onopen_ws (){
|
// let sw_int = setInterval(function (){
|
||||||
|
// if (chatSocket.readyState > 1){
|
||||||
|
// chatSocket = new WebSocket(ws_url)
|
||||||
|
// // chatSocket.onopen = function (){
|
||||||
|
// } else if (chatSocket.readyState === 1){
|
||||||
|
// clearInterval(sw_int)
|
||||||
|
// } else {
|
||||||
|
// console.log("connecting...")
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// },1000)
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
// }
|
||||||
|
function restart_ws (){
|
||||||
let sw_int = setInterval(function (){
|
let sw_int = setInterval(function (){
|
||||||
if (chatSocket.readyState > 1){
|
if (chatSocket.readyState > 1){
|
||||||
chatSocket = new WebSocket(ws_url)
|
// chatSocket = new WebSocket(ws_url)
|
||||||
|
init_ws()
|
||||||
// chatSocket.onopen = function (){
|
// chatSocket.onopen = function (){
|
||||||
} else if (chatSocket.readyState === 1){
|
} else if (chatSocket.readyState === 1){
|
||||||
|
|
||||||
clearInterval(sw_int)
|
clearInterval(sw_int)
|
||||||
|
console.log("open")
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
console.log("connecting...")
|
console.log("connecting...")
|
||||||
}
|
}
|
||||||
@@ -46,13 +66,41 @@ function onopen_ws (){
|
|||||||
},1000)
|
},1000)
|
||||||
}
|
}
|
||||||
|
|
||||||
chatSocket.onopen = function (){
|
function init_ws () {
|
||||||
console.log("open")
|
chatSocket = new WebSocket(ws_url);
|
||||||
|
|
||||||
|
if (chatSocket.readyState !== 1) {
|
||||||
|
restart_ws()
|
||||||
|
}
|
||||||
|
|
||||||
|
chatSocket.addEventListener('open',socket_open)
|
||||||
|
chatSocket.addEventListener('close',socket_close)
|
||||||
|
chatSocket.addEventListener('message',wsReceiveData)
|
||||||
|
|
||||||
|
// chatSocket.onmessage = function (e) {
|
||||||
|
// wsReceiveData(e);
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
// chatSocket.onclose = function (){
|
||||||
|
// console.log("closed")
|
||||||
|
// setTimeout(restart_ws,1000)
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// chatSocket.onopen = function (){
|
||||||
|
// console.log("open")
|
||||||
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
function socket_open(e){
|
||||||
|
console.log("connect")
|
||||||
|
}
|
||||||
|
|
||||||
|
function socket_close(e){
|
||||||
|
console.log("closed")
|
||||||
|
setTimeout(restart_ws,1000)
|
||||||
|
}
|
||||||
// var window_messages = document.querySelector(".container-messages")
|
// var window_messages = document.querySelector(".container-messages")
|
||||||
|
|
||||||
// function getNewMessageSession (){
|
// function getNewMessageSession (){
|
||||||
|
|||||||
@@ -9,22 +9,25 @@
|
|||||||
|
|
||||||
|
|
||||||
<script src='{% static "js/jquery_v3_6_4.js" %}'> </script>
|
<script src='{% static "js/jquery_v3_6_4.js" %}'> </script>
|
||||||
|
<script src='{% static "js/chat_sockets.js" %}'></script>
|
||||||
|
<script src="{% static "js/global_js.js" %}"></script>
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
{#var user_id = {{ user.id }}#}
|
{#var user_id = {{ user.id }}#}
|
||||||
ws_url = `ws://{% get_ws_address %}/ws/socket-server/?user_id={{ user.id }}`;
|
ws_url = `ws://{% get_ws_address %}/ws/socket-server/?user_id={{ user.id }}`;
|
||||||
let chatSocket = new WebSocket(ws_url);
|
var chatSocket;
|
||||||
|
init_ws()
|
||||||
const beep = new Audio('/static/sounds/beep_2.mp3')
|
const beep = new Audio('/static/sounds/beep_2.mp3')
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script src='{% static "js/chat_sockets.js" %}'></script>
|
|
||||||
|
|
||||||
|
|
||||||
<link rel="stylesheet" href="{% static 'css/styles.css' %}">
|
<link rel="stylesheet" href="{% static 'css/styles.css' %}">
|
||||||
|
|
||||||
<link rel="stylesheet" href="{% static 'css/styles(boris).css' %}" >
|
<link rel="stylesheet" href="{% static 'css/styles(boris).css' %}" >
|
||||||
|
|
||||||
<script src="{% static "js/global_js.js" %}"></script>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user