Games::AssaultCube::MasterserverQuery - Queries an AssaultCube masterserver for the list of servers


        use Games::AssaultCube::MasterserverQuery;
        my $query = Games::AssaultCube::MasterserverQuery->new;
        #my $query = Games::AssaultCube::MasterserverQuery->new( 'http://foo.com/get.do' );
        #my $query = Games::AssaultCube::MasterserverQuery->new({ server => 'http://foo.com/get.do', timeout => 5 });
        my $response = $query->run;
        if ( defined $response ) {
                print "There is a total of " . $response->num_servers " servers in the list!\n";
        } else {
                print "Masterserver is not responding!\n";


This module queries an AssaultCube masterserver for the list of servers.


This module queries an AssaultCube masterserver for the list of servers. It has been tested extensively on the AssaultCube masterserver and the CubeStats.net masterserver.

WARNING: This module doesn't parse the XML output, only the regular "list" format! In the future XML parsing will be added as XML support gets stable in the masterserver.


This module uses Moose, so you can pass either a hash, hashref, or a server to the constructor. Passing a string means we're passing in a server URI. If you want to specify more options, please use the hash/hashref method.

The attributes are:


The server hostname or ip in HTTP URI format.

Defaults to the AssaultCube masterserver: http://masterserver.cubers.net/cgi-bin/AssaultCube.pl/retrieve.do?item=list


The timeout waiting for the server response in seconds. Defaults to 30.

WARNING: We use alarm() internally to do the timeout. If you used it somewhere else, it will cause conflicts and potentially render it useless. Please inform me if there's conflicts in your script and we can try to work around it.


The LWP::UserAgent object we will use. Handy if you want to override it's configuration.


Currently, there is only one method: run(). You call this and get the response object back. For more information please look at the Games::AssaultCube::MasterserverQuery::Response class. You can call run() as many times as you want, no need to re-instantiate the object for each query.

WARNING: run() will die() if errors happen. For sanity, you should wrap it in an eval.


You can modify some attributes before calling run() on the object. They are:


Same as the constructor


Same as the constructor


You can modify the HTTP::Request object, if needed to override stuff.


Apocalypse <apocal@cpan.org>

Props goes to Getty and the BS clan for the support!

This project is sponsored by http://cubestats.net


Copyright 2009 by Apocalypse

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.