This commit is contained in:
2023-08-12 13:14:26 +03:00
parent 7c7452a93d
commit 1d64583697
3 changed files with 38 additions and 29 deletions

View File

@@ -43,11 +43,19 @@ chatSocket.onmessage = function (e) {
// console.log("open") // console.log("open")
// } // }
chatSocket.onopen = function(){
console.log("open")
}
chatSocket.onclose = function () { chatSocket.onclose = function () {
console.log("close") console.log("close")
} }
chatSocket.onopen = function(){ function sendMessageSocket (data) {
console.log("open") //
chatSocket.send('A');
chatSocket.send(JSON.stringify(data))
// }
} }

View File

@@ -34,7 +34,7 @@
// // check_new_messages_timeout(60000,it_set_func,it_func) // // check_new_messages_timeout(60000,it_set_func,it_func)
// // } // // }
// //
// function check_new_messages_timeout(timeout_time=short_timeout){ function check_new_messages_timeout(timeout_time=1000){
// if (check_msg){ // if (check_msg){
// clearInterval(check_msg) // clearInterval(check_msg)
// } // }
@@ -77,7 +77,7 @@
// //
// }, // },
// timeout_time) // timeout_time)
// } }
// //
// //
// //

View File

@@ -225,29 +225,30 @@ function sendMessage(id_ticket=null,sender,receiver){
$.ajax({ // $.ajax({
headers: { "X-CSRFToken": $('input[name=csrfmiddlewaretoken]').val() }, // headers: { "X-CSRFToken": $('input[name=csrfmiddlewaretoken]').val() },
url: '/ru/messages/send_msg/', // url: '/ru/messages/send_msg/',
type: "POST", // type: "POST",
// async: true, // // async: true,
cache: false, // cache: false,
processData: false, // processData: false,
contentType: false, // contentType: false,
// enctype: 'json', // // enctype: 'json',
data: JSON.stringify(data), // data: JSON.stringify(data),
success: function(data){ // success: function(data){
getNewMessageSession() // getNewMessageSession()
//
document.querySelector(".container-messages").innerHTML = data.html; // document.querySelector(".container-messages").innerHTML = data.html;
document.querySelector(".enter-message-inp").focus() // document.querySelector(".enter-message-inp").focus()
//
}, // },
error: function (data){ // error: function (data){
//
document.querySelector(".container-messages").innerHTML = data.responseJSON.error; // document.querySelector(".container-messages").innerHTML = data.responseJSON.error;
document.querySelector(".enter-message-inp").focus() // document.querySelector(".enter-message-inp").focus()
} // }
}); // });
sendMessageSocket(data)
} }
} }