Skip to content
ext edited this page Dec 29, 2011 · 4 revisions
  1. summary Specification of client-server communication.

Table of Contents

About the protocol

The protocol should be simple and human-readable. Much like IRC, it is string-based and above TCP.

Commands and responses

Commands must start with a number that must be included in the response. For example:

  28 NEWUSER foo bar
  28 OK

Broadcast messages

The server sometimes send broadcast messages to all clients. For example, when a new user is created, the server will send this message:

  BROADCAST NEW_PLAYER 1 foo

Clients cannot send broadcast messages.

Compound types

Lists and dictionaries are sent using the JSON encoding.

Client initiated commands

CAPS=

Get server capabilities

Server replies

 * OK <CAPS>

PING

Standard PING command, is the server still alive?

Server replies

 * PONG <STRING>

NEWUSER

Register a new user. Client must do LOGIN after this.

Server replies

 * OK
 * NOT_OK

LOGIN

Try to login.

Server replies

 * <PLAYERID>
 * NOT_OK

SET =

Try to set a property

Server replies

 * OK
 * NOT_OK

LIST_OF_ENTITIES

Ask the server for a visible object list.

Server replies

 * JSON encoded list of entities

MOVE

Tell the server that we are now interested in objects close to POS.

Server replies

 * Difference list, objects to forget, new objects
 * NOT_OK (when can this error occur?)

TYPEINFO

Get info about specified type.

Server replies

 * Dict of information on the type.

ENTINFO

Get info of specified entity

Server replies

 * List of information on the object
 * NOT_OK (User is not allowed to see this object at all)

PLAYERS

Get list of players (all players or only players that are logged in right now).

Server replies

 * List of player ids

PLAYERINFO

Get info on specified player, including oneself.

Server replies

 * Dictionary of players (player id as key, player name as value)

ENTACTION

Objects may have actions, do a specific one. See EntityActions

Server replies

 * RET_VAL
 * NOT_OK

ACTION

The game has a few actions, like "leave", "message player", and so forth. Do one such action.

Server replies

 * RET_VAL
 * NOT_OK

Server initiated commands

PING

Is the player still connected?

Client replies

 * PONG <STRING>

MOVE

Ask the client to move to POS, where it will likely be more interesting to be.

Client replies

 * OK

GAMEINFO_UPDATE

Things like players joining, The game being over and so on. The clients may want to request info on all other players to show a pretty scoreboard or sth.

Client replies

 * OK

NEWENT

A new entity shall be visible to the player.

Client replies

 * OK

CASH

Informs client that the amount of cash has changed. No reply.

DELENT

This entity is no longer interesting

Client replies

 * OK

UPDENT []

Update some property of Entity.

Client replies

  * OK