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.
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:
$::server_data{'protocol'}
hold
the protocol used to send the data. It will be
MSDP or
GMCP.
$::server_data{'data'}
holds the
data received. The actual contents vary depending on what has been
received, but in most cases it will be a reference to a hash with
entries for each variable sent by the server. If the value is
undef, that means that the server sent the
null/undefined object (this is not possible in all protocols). If
this key does not exist in the hash, the server did not send any
variables at all (again, not possible in all
protocols).
$::server_data{'error'}
is set in
case KildClient could not parse the data sent by the server. In this
case, this variable holds the error message, and
$::server_data{'data'}
contains the raw data
received.
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.