As mentinoed previously, to receive server data, bind a hook to
the OnServerData
event. See Chapter 12, Hooks.
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.