Apocalypse > Games-AssaultCube-0.04 > Games::AssaultCube::MasterserverQuery

Download:
Games-AssaultCube-0.04.tar.gz

Dependencies

Annotate this POD

Website

View/Report Bugs
Module Version: 0.04   Source  

NAME ^

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

SYNOPSIS ^

        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";
        }

ABSTRACT ^

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

DESCRIPTION ^

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.

Constructor

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:

server

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

timeout

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.

useragent

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

Methods

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.

Attributes

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

timeout

Same as the constructor

useragent

Same as the constructor

request

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

AUTHOR ^

Apocalypse <apocal@cpan.org>

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

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

COPYRIGHT AND LICENSE ^

Copyright 2009 by Apocalypse

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

syntax highlighting: