Update Redditlikechatter.HTML
This commit is contained in:
parent
969abf1c45
commit
0f0696a435
1 changed files with 10 additions and 3 deletions
|
@ -21,20 +21,27 @@
|
|||
const messageInput = document.getElementById('message');
|
||||
const sendButton = document.getElementById('send');
|
||||
|
||||
// Create a WebSocket connection using your WebSocket service's endpoint
|
||||
|
||||
const socket = new WebSocket('wss://free.blr2.piesocket.com/v3/1?api_key=C1ZujiijYNPNj8gvuGXhIPKsDR4WolCCKOBzMdbM¬ify_self=1');
|
||||
|
||||
// Handle WebSocket open event
|
||||
|
||||
socket.addEventListener('open', () => {
|
||||
sendButton.disabled = false; // Enable the send button when the WebSocket is open
|
||||
});
|
||||
|
||||
// Handle incoming messages from the server
|
||||
|
||||
socket.addEventListener('message', event => {
|
||||
const message = event.data;
|
||||
appendMessageToChatbox(message);
|
||||
});
|
||||
|
||||
|
||||
messageInput.addEventListener('keydown', event => {
|
||||
if (event.key === 'Enter') {
|
||||
sendMessage();
|
||||
}
|
||||
});
|
||||
|
||||
sendButton.addEventListener('click', sendMessage);
|
||||
|
||||
function sendMessage() {
|
||||
|
|
Loading…
Add table
Reference in a new issue