This will be possible in the next update fyi :-):
const ws = new WebSocket('wss://server.com/game');
ws.onopen = () => console.log('Connected');
ws.onmessage = (e) => console.log('Data:', e.data);
ws.onerror = (e) => console.error('Error:', e);
ws.onclose = () => console.log('Disconnected');
ws.send(JSON.stringify({ action: 'move', x: 10, y: 20 }));