This commit is contained in:
2023-08-24 15:18:58 +03:00
parent 40fc623123
commit fa360267a0
3 changed files with 44 additions and 4 deletions

View File

@@ -0,0 +1,5 @@
function filters_func_find_route_main (){
let urls_for_els = {
'road_url':''
}
}

View File

@@ -1,8 +1,13 @@
$(document).ready(function (){
getNewMessageSession()
})
// $(document).ready(function (){
// getNewMessageSession()
// })
// window.onfocus = function () {
// getSocketState()
// }
function getNewMessageSession(){
// let window_messages = document.querySelector(".container-messages")
// let new_timeout_time;
// if (window_messages !== null){
@@ -17,6 +22,36 @@ function getNewMessageSession(){
// check_new_messages_timeout(new_timeout_time)
}
// function getSocketState () {
chatSocket.onclose = function (){
console.log("closed")
setTimeout(onopen_ws,1000)
}
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)
}
chatSocket.onopen = function (){
console.log("open")
}
// }
// var window_messages = document.querySelector(".container-messages")

View File

@@ -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);
let chatSocket = new WebSocket(ws_url);
const beep = new Audio('/static/sounds/beep_2.mp3')
</script>