Merge remote-tracking branch 'origin/main'
This commit is contained in:
@@ -4,17 +4,7 @@
|
||||
// localStorage.setItem('senderName', senderName);
|
||||
// }
|
||||
//
|
||||
// chatSocket.onmessage = function (e) {
|
||||
// let data = JSON.parse(e.data);
|
||||
// console.log('Data:', data);
|
||||
//
|
||||
// if (data.type === 'chat') {
|
||||
// let messages = document.getElementById('messages')
|
||||
// let cssClass = data.sender === senderName? 'sender' : 'receiver';
|
||||
// messages.insertAdjacentHTML('beforeend', `<div class="${cssClass}">
|
||||
// <p>${data.message}</p>
|
||||
// </div>`)
|
||||
// }
|
||||
// }
|
||||
// let form = document.getElementById('form')
|
||||
// form.addEventListener('submit', (e) => {
|
||||
@@ -42,20 +32,31 @@ chatSocket.onmessage = function (e) {
|
||||
// chatSocket.onopen = function () {
|
||||
// console.log("open")
|
||||
// }
|
||||
|
||||
chatSocket.onopen = function(){
|
||||
console.log("open")
|
||||
function open_socket () {
|
||||
chatSocket.onopen = function(){
|
||||
console.log("open")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
chatSocket.onclose = function () {
|
||||
console.log("close")
|
||||
}
|
||||
|
||||
function sendMessageSocket (data) {
|
||||
//
|
||||
|
||||
chatSocket.send(JSON.stringify(data))
|
||||
// open_socket()
|
||||
chatSocket.send(JSON.stringify(data))
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
chatSocket.onmessage = function (e) {
|
||||
let data = JSON.parse(e.data);
|
||||
console.log('Data:', data);
|
||||
console.log("return")
|
||||
if (data.type === 'chat'){
|
||||
document.querySelector(".container-messages").innerHTML = data.html;
|
||||
document.querySelector(".enter-message-inp").focus()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user