const socket = new WebSocket('ws://localhost:3000'); socket.addEventListener('open', (event) => { console.log('connecté'); }); socket.addEventListener('message', (event) => { console.log(event.data); }); socket.addEventListener('close', (event) => { console.log('Connexion au serveur WebSocket fermée'); }); function main(){ socket.send(JSON.stringify({type: "connect"})); socket.send(JSON.stringify({ type: "update", data: { id: 0, x: 0, y: 0 } })) }