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")
// }
chatSocket.onopen = function(){
console.log("open")
}
chatSocket.onclose = function () {
console.log("close")
}
chatSocket.onopen = function(){
console.log("open")
chatSocket.send('A');
}
function sendMessageSocket (data) {
//
chatSocket.send(JSON.stringify(data))
// }
}

View File

@@ -34,7 +34,7 @@
// // 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){
// clearInterval(check_msg)
// }
@@ -77,7 +77,7 @@
//
// },
// timeout_time)
// }
}
//
//
//

View File

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