Skip to content
Michael Barrett edited this page Sep 11, 2015 · 3 revisions

A command is a JavaScript object that follows a contract and is used to send data to/from client applications. Commands can be singular commands, or a batch of commands. The basic command contract is as follows:

{
    command: 'Some command name here'
}

Beyond the command property, you can specify any arbitrary key/value pairing that you like to add data to the command for the client application to consume:

{
    command: 'playerPosition',
    playerId: 2,
    x: 120,
    y: 400
}

Batch commands

Besides command, the other reserved keyword in command objects is batch. If batch is set to true on a command object, the structure of the object changes to contain a list of command objects to send at the same time:

{
    batch: true,
    commands: [
        {
            command: 'someCommand'
        },
        {
            command: 'someOtherCommand'
        }
    ]
}

This allows for Clients to package up multiple commands and send them over the wire at once in order to reduce flooding. It is also used when Client objects are in Tick Mode

Clone this wiki locally