cURL
curl --request GET \ --url https://api.example.com/api/servers/:server/ws
wss://wings.example.com/api/servers/:server/ws?token=<jwt-token>
throttled
["global"]
{ "event": "event_name", "args": ["arg1", "arg2"] }
{ "event": "send command", "args": ["say Hello World"] }
{ "event": "send logs", "args": [] }
{ "event": "send stats", "args": [] }
{ "event": "set state", "args": ["start"] // start, stop, restart, kill }
{ "event": "console output", "args": ["[10:30:15] [Server thread/INFO]: Player joined the game"] }
{ "event": "status", "args": ["running"] // offline, starting, running, stopping }
{ "event": "stats", "args": ["{\"memory_bytes\":536870912,\"cpu_absolute\":25.5,...}"] }
{ "event": "token expiring", "args": [] }
{ "event": "token expired", "args": [] }
{ "event": "daemon message", "args": ["Server is starting..."] }
{ "event": "install output", "args": ["Downloading server files..."] }
{ "event": "install started", "args": [] }
{ "event": "install completed", "args": [] }
const ws = new WebSocket( 'wss://wings.example.com/api/servers/8d3f9a2e-5c7b-4f1e-9d2a-6e8f1c3b5a7d/ws?token=eyJhbGc...' ); ws.onopen = () => { console.log('Connected to server websocket'); // Request logs ws.send(JSON.stringify({ event: 'send logs', args: [] })); }; ws.onmessage = (event) => { const data = JSON.parse(event.data); switch(data.event) { case 'console output': console.log('Console:', data.args[0]); break; case 'status': console.log('Status changed to:', data.args[0]); break; case 'stats': const stats = JSON.parse(data.args[0]); console.log('CPU:', stats.cpu_absolute, 'Memory:', stats.memory_bytes); break; } }; ws.onclose = (event) => { console.log('Disconnected:', event.code, event.reason); }; // Send a command function sendCommand(command) { ws.send(JSON.stringify({ event: 'send command', args: [command] })); }
1000
1001
1006
1012
4409
router/router_server_ws.go:27