Last active
June 14, 2020 13:29
-
-
Save shriyaRam/49cf2823bbc3d924f700b7c1ea8a12b0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//send messages | |
sendbtn.addEventListener("click", ()=>{ | |
channel.sendMessage({ text: msg.value }).then(() => { | |
/* Your code for handling events, such as a channel message-send success. */ | |
chatbox.innerHTML += "<div class='message_holder'><span class='chat user1'>"+ msg.value + "</span></div>"; | |
console.log("Successfully sent message!"); | |
}).catch(error => { | |
/* Your code for handling events, such as a channel message-send failure. */ | |
console.log("Error sending message!"); | |
}); | |
}) | |
if(flag == true){ | |
//receive channel messages | |
channel.on('ChannelMessage', ({ text }, senderId) => { // text: text of the received channel message; senderId: user ID of the sender. | |
/* Your code for handling events, such as receiving a channel message. */ | |
chatbox.innerHTML +="<div class='message_holder'><span class='chat user2'>"+ text + "</span></div>"; | |
msg.value=""; | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment