const io = require('socket.io-client'); const socket = io('http://localhost:3000'); socket.on('connect', () => { console.log('Connected to server'); }); socket.on('disconnect', () => { console.log('Disconnected from server'); }); socket.on('chat message', (msg) => { console.log(`Received message: ${msg}`); }); function sendMessage(message) { socket.emit('chat message', message); } sendMessage('Helló a klienstől');