Chapter 16. Out-of-band server data

KildClient support some protocols that allow the server to send data to the client in a way that can be easily parsed (unlike prompts, for example) and that is not directly visible to the user. We call this out-of-band data. For example, the server could send your character stats (hp, mana, etc), so that a plugin can display this data in a more convenient form.

Currently, two such protocols are supported: MSDP and GMCP (sometimes called ATCP2).

By default, nothing is done with the data that is received. A hook must be bound to the OnServerData event to handle the data that is received. Even so, KildClient does nothing with the data (other than to parse it in a form that's easy to be used in Perl scripts and protocol-independent): it's up to your code to do anything with it. For example, KildClient does not store any previous values of any variable, it is up to you to store what you want.

16.1. Receiving server data

As mentinoed previously, to receive server data, bind a hook to the OnServerData event. See Chapter 12.

Inside the hook, the %::server_data variable holds the data received. The elements of the hash can vary depending on the protocol and what was received. To view what is received in each message, you can use the serverdatadumper plugin. Just load it, and whenever a server data message is received, the contents of the %::server_data will be displayed.

Here's a general description of the elements, followed by specifics to each protocol if appropriate:

16.1.1. GMCP data

The GMCP protocol has the concept of packages (with optional subpackages) and message names. These are stored in $::server_data{'package'}, $::server_data{'subpackage'} and $::server_data{'message'} if they are included in the message.

The actual data in this protocol is sent using the JSON format. The Perl module JSON is used to parse the data, see its documentation if you want specific details on how objects are represented.