Files
il/resources/public/js/index.js
2026-07-01 22:38:29 -06:00

12 lines
329 B
JavaScript

const proto = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
const socket = new WebSocket(`${proto}//${window.location.host}/ws`);
socket.onopen = () => {
console.log('Connected to server...');
socket.send('world');
};
socket.onmessage = (e) => {
console.log('Received message from server: ', e.data);
};