AAGRINDER socket.io api

From AAGRINDER wiki
Jump to navigationJump to search

AAGRINDER uses the socket.io library for most of the communication between the AAGRINDER server and the AAGRINDER clients. This page describes all the different messages that can be sent between the server and the client over socket.io.

Endpoints on the server

This section describes all the messages that can be sent from the AAGRINDER client to the AAGRINDER server.

The items under Data need to be present in the message, otherwise the message is ignored. The examples are written as code you would run on the client.

Login

Attempts to log in a player

Endpoint

'login'

Data

{ username:[string], password:[string] }

Sample code

socket.emit('login', {username:'original', password:'hihi'});

Chat message

Sends a chat message to all other clients, or runs a server-side command. Only works if player is logged in.

Endpoint

'chat'

Data

{ message:[string] }

Sample code

socket.emit('chat', {message:'hi!'});

Change player color

Endpoint

'changecolor'

Game tick

Endpoint

't'

Submit debug logs

Endpoint

'debuglog'


Endpoints on the client

This section describes all the messages that can be received on the AAGRINDER client from the AAGRINDER server.

The items under Data are always present in the message received from the server, unless they are marked with ?, in which case they are optional. The examples are written as code you would run on the client.

Login success

Endpoint

'loginsuccess'

Sample code

socket.on('loginsuccess', data => console.log(data));

Login error

Endpoint

'loginerror'

Sample code

socket.on('loginerror', data => console.log(data));

Force reload

Endpoint

'FORCERELOAD'

Sample code

socket.on('FORCERELOAD', data => console.log(data));

Chat message

Endpoint

'chat'

Sample code

socket.on('chat', data => console.log(data));

Terrain update

Endpoint

't'

Sample code

socket.on('t', data => console.log(data));