Update Redditlikechatter.HTML

This commit is contained in:
Dangrainage 2023-08-28 23:18:19 +02:00 committed by GitHub
parent 969abf1c45
commit 0f0696a435
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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&notify_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() {