This page explains how messages are sent between the client and server. Throughout this page, \0, \1 and \2 are used to represent the binary characters with values 0, 1 and 2 respectively.
Client to Server
Most command sent by the client can be represented by an id for the command type, an one-dimentional array for the data.
For example, to edit a contact, the command type is 5, and the data is an array containing the group, the id and the name of the contact.
The format of a typical command is as follows:
ln=<len>\0id=<userid>\0cm=<cmdid>\0ms=<data>
where
- \0 is the null character
- <len> is the length of everything after the first \0
- <userid> is the username
- <cmdid> is the command id
- <data> is the command data, each element separated by \1
Integers are all sent as plain text.
For example, to edit a contact, the following data can be sent:
ln=66\0id=27123456789\0cm=Services\1joebanker@services.mxit.co.za\1JoeBanker
Server to Client
Most commands sent by the server to the client can be represented by an id for the command type and a two-dimentional array for the data.
The first element of the array is an array containing the response code, and optionally with a response message.
\1 is used to separate the elements of the inner arrays, and \0 to separate the inner arrays.
The message is in the following format:
ln=<len>\0<cmdid>\0<data>
For example:
ln=94\03\00\0Services\1joebanker@services.mxit.co.za\1JoeBanker\11\18\10\2Friends\1john@gmail.com\1John\15\11\13\2
In this case data was the array:
[[0], ['Services', 'joebanker@services.mxit.co.za', 'JoeBanker', 1, 8, 0], ['Friends', 'john@gmail.com', 'John', 5, 1, 3], []]
0 is the response code.
Commands may also be chained together with the \2 character:
ln=<len>\0<cmdid1>\0<data1>\2<cmdid2>\0<data2>\2<cmdid3>\0<data3>
Response messages
To almost every command from the client, the server will send a response. If the command was successfull, only the reponse code 0 is returned. The response code 99 is used to display a message to the user. Other response codes may contain more data.
Examples: In response to a message sent: data = [[0]]
ln=5\010\00
Error with the message: data =
[[99, 'Message cannot be sent]] ln=28\010\099\1Message cannot be sent
Usually when the response code is nonzero, no data except for the response message will be present.