16.1. Receiving server data

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:

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.