Skip to content

WebSocket commands and responses

Carlos Mesa edited this page Aug 24, 2019 · 19 revisions

WebSocket commands and responses

Technical info below! This is only important to you if you are considering creating a new client or if you want to extend WebConsole possibilities. Below is a detailed list containing all current WebConsole commands, along with the data that the server will send in response to these commands. This information applies to WebConsole v1.1

Commands

LOGIN (password)

Logs user in into server. This is the first command client should send to server. Login is required in order to run any of the other commands.

Example usage: LOGIN myPassw0rd

Responds with:

  • 200 If password was correct
  • 401 If password was incorrect

EXEC (command)

Execute a command into the Minecraft Server console as if you were typing into the real console.

Example usage: EXEC say Hello from WebConsole!

Responds with:
This message does not generate a response itself, but WebConsole will send you the console output generated for your command with a 010 message.

PLAYERS

Ask server for the number of connected and total players.

Example usage: PLAYERS

Responds with:
1000 Players object

CPUUSAGE

Ask server for the CPU usage percentage.

Example usage: CPUUSAGE

Responds with:
1001 CPUUsage object

RAMUSAGE

Ask server for the amount of free, used and total RAM for that Java VM instance.

Example usage: RAMUSAGE

Responds with:
1002 RAMUsage object

Responses

All responses are sent into a JSON string. Every response will contain a status and statusDescription parameter to allow the client know the response type. All possibilities are shown below.

010 Console Output

Sends a line printed in Minecraft console.

Extra parameters:

  • message: Contains the console line printed into real console.

Example response:

{status: 10, statusDescription: "Console Output", message: "[Server] Hello from WebConsole!"}

200 Processed

Tells the client that a previously sended command was sucessfully processed.

Extra parameters:

  • respondsTo: Command that originated this response.
  • message: User-readable message for this object.

Example response:

{status: 200, statusDescription: "Processed", respondsTo: "LOGIN ********", message: "Logged In"}

400 Unknown Command

A sended command does not exist or was not understood by server.

Extra parameters:

  • respondsTo: Command that originated this response.
  • message: User-readable message for this object.

Example response:

{status: 400, statusDescription: "Unknown Command", respondsTo: "ESEC esec command do not exist!", message: "Unknown command"}

401 Login Required

First message that client will receive when connecting to a server. Informs that login is required with a valid password in order to start executing commands.

Extra parameters:

  • message: User-readable message for this object.

Example response:

{status: 401, statusDescription: "Login Required", message: "Connection started, waiting login"}

1000 Players

Retrieves number of connected and total players in the server

Extra parameters:

  • connectedPlayers: Number of connected players.
  • maxPlayers: Maximum number of player slots.
  • message: User-readable message for this object.

Example response:

{status: 1000, statusDescription: "Players", connectedPlayers: 0, maxPlayers: 20, message: "Currently 0 connected players for a maximum of 20"}

1001 CPU Usage

Retrieves percentage of CPU used by the host machine.

Extra parameters:

  • usage: Percentage of CPU used by the host machine.
  • message: User-readable message for this object.

Example response:

{status: 1001, statusDescription: "CPU Usage", usage: 8.7, message: "Usage is 8.7%"}

1002 RAM Usage

Retrieves amount of free, used and total RAM for that Java VM instance.

Extra parameters:

  • free: Free amount of memmory.
  • used: Used amount of memmory.
  • max: Maximum amount of memmory.
  • message: User-readable message for this object.

Example response:

{"status":1002,"statusDescription":"RAM Usage","free":471,"used":519,"max":990,"message":"471 free, 519 used, 990 maximum memmory"}
Clone this wiki locally