Eris
1.4.0
|
Meta encapsulates the meta-game system, including the meta-server protocol and queries. More...
#include <Metaserver.h>
Public Types | |
enum | MetaStatus { INVALID = 0, VALID, GETTING_LIST, QUERYING } |
Public Member Functions | |
Meta (boost::asio::io_service &io_service, EventService &eventService, const std::string &msv, unsigned int maxQueries) | |
Create a Metaserver object, which manages all interaction with the metaserver itself, and querying active game servers. More... | |
size_t | getGameServerCount () const |
Return the total number of game servers the meta server knows about. More... | |
const ServerInfo & | getInfoForServer (size_t index) const |
Retrive one of the servers. More... | |
void | queryServerByIndex (size_t index) |
Query a specific game server; emits a signal when complete. | |
void | refresh () |
Refresh the entire server list. More... | |
void | cancel () |
Cancel outstanding refresh / queries. More... | |
void | dispatch () |
MetaStatus | getStatus () const |
Public Attributes | |
sigc::signal< void, const ServerInfo & > | ReceivedServerInfo |
Emitted when information about a server is received. | |
sigc::signal< void, int > | CompletedServerList |
Emitted once the complete list of servers has been retrived from the metaserver. More... | |
sigc::signal< void > | AllQueriesDone |
Emitted when the entire server list has been refreshed. | |
sigc::signal< void, const std::string & > | Failure |
Indicates a failure (usually network related) has occurred. More... | |
Protected Member Functions | |
virtual void | objectArrived (const Atlas::Objects::Root &obj) |
void | doFailure (const std::string &msg) |
void | queryFailure (MetaQuery *q, const std::string &msg) |
void | query () |
void | queryTimeout (MetaQuery *q) |
void | metaTimeout () |
void | connect () |
initiate a connection to the meta-server : this will issue a keep-alive followed by a list request. More... | |
void | disconnect () |
tear down an existing connection to the server | |
Friends | |
class | MetaQuery |
Meta encapsulates the meta-game system, including the meta-server protocol and queries.
Eris::Meta::Meta | ( | boost::asio::io_service & | io_service, |
EventService & | eventService, | ||
const std::string & | msv, | ||
unsigned int | maxQueries | ||
) |
Create a Metaserver object, which manages all interaction with the metaserver itself, and querying active game servers.
Clients might create this object when showing a 'server list' dialog, and use the signals and accessors to pouplate the list. Signals and methods are provided to support common things like displaying query progress, and canceling queries.
msv | The metaserver to query, specified as a hostname. Usually metaserver.worldforge.org, but that's up to you. |
maxQueries | The maximum number of game server queries to have active at any one time. 10 is a sensible value, too low and querying will take a long time, too high and .... I'm not sure. |
References disconnect().
void Eris::Meta::cancel | ( | ) |
Cancel outstanding refresh / queries.
This is primarily intended for use with 'Refresh', which might takes several minutes to complete. Note that 'CompletedServerList' is not emitted following cancellation.
References disconnect(), INVALID, and VALID.
Referenced by disconnect().
|
protected |
initiate a connection to the meta-server : this will issue a keep-alive followed by a list request.
References disconnect(), and GETTING_LIST.
Referenced by refresh().
size_t Eris::Meta::getGameServerCount | ( | ) | const |
Return the total number of game servers the meta server knows about.
const ServerInfo & Eris::Meta::getInfoForServer | ( | size_t | index | ) | const |
Retrive one of the servers.
Note the ServerInfo object may be invalid if the server has not yet been queried, or has timedout or otherwise failed to answer the query.
void Eris::Meta::refresh | ( | ) |
Refresh the entire server list.
This will clear the current list, ask the meta-server for each game server, and then issue a query against every returned server. This process can take a large amount of real-time as the number of game servers increases. Completion of the entire refresh is indicated by the 'CompletedServerList' signal.
References connect(), disconnect(), and VALID.
sigc::signal<void, int> Eris::Meta::CompletedServerList |
Emitted once the complete list of servers has been retrived from the metaserver.
Argument is the total number of servers in the list
Referenced by disconnect().
sigc::signal<void, const std::string&> Eris::Meta::Failure |
Indicates a failure (usually network related) has occurred.
The server list will be cleared, and the status set to INVALID.
Referenced by disconnect().