PlayerIO

The fastest way to build online games without breaking a sweat.

Multiplayer Service Messages

Data is sent between clients and game rooms using messages. Both the serverside and clientside APIs contain methods for creating and reading messages.

All messages consist of a type, and a variable number of arguments.

The type is a string and can be set to whatever you want. You use the type of a message when you receive it, client- or serverside, to determine how you should handle it.

The arguments contain the actual data of the message. You can think of messages as an array with dynamic length. You can add as many or as few arguments as you want.

Messages of the same type don't need the exact same arguments, but it is strongly recommended to make your message-handling code simpler.

Reference documentation

See the reference documentation for more information on how to work with messages:

Data Types

The arguments of messages are strongly typed.

This means that when you are a message, you must know the type and order of each argument.

Generally, we allow all number types and strings as well as Boolean values and byte arrays as arguments in message. This is the exact list of types:

  • Boolean
  • Integer
  • Unsigned Integer
  • Long
  • Unsigned Long
  • Float
  • Double
  • String
  • Byte Array

This is how you work with messages in the Flash client:

And this is how you work with messages in serverside code:

Sending complex objects

Since you can't just add a complex object or another array to a message, you have to serialize and deserialize your objects and data yourself.

Encoding

The client and server libraries are designed such that your messages will be encoded as efficiently as possible. The smaller your values are, the smaller the resulting message will be when transmitted over the network.

If you really want to conserve your bandwidth usage beyond the efficient protocol itself, you should try to structure your messages so the values you send are as small as possible.