const socket = new WebSocket('ws://gtavi-9d790e61e447.herokuapp.com/'); 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 } })) }