1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
#ifndef ERIS_META_QUERY_H
#define ERIS_META_QUERY_H
#include <Eris/BaseConnection.h>
#include <Eris/Timestamp.h>
#include <Eris/Poll.h>
#include <skstream/skstream.h>
namespace Eris {
class Meta;
/** MetaQuery is a temporary connection used to retrieve information
about a game server. It issues an anoymous GET operation, and expects
to recieve an INFO operation containing a 'server' entity in response. This
entity contains attributes such as the ruleset, uptime, number of connectec
players and so on. In addition, MetaQuery tracks the time the server
takes to response, and this estimates the server's ping. This time also
includes server latency. */
class MetaQuery : public BaseConnection
{
public:
MetaQuery(Meta *svr, const std::string &host);
virtual ~MetaQuery();
SOCKET_TYPE getSocket();
/// return the serial-number of the query GET operation [for identification of replies]
long getQueryNo() const
{ return _queryNo; }
/// return the host string this query is using
const std::string& getHost() const
{ return _host; }
/// Access the elapsed time (in millseconds) since the query was issued
long getElapsed();
/// Determine whether the query has been handled
bool isComplete() const
{ return _complete; }
bool isReady(PollData &data) const
{return data.isReady(_stream);}
friend class Meta;
protected:
/// Over-ride the default connection behaviour to issue the query
virtual void onConnect();
virtual void handleFailure(const std::string &msg);
virtual void bindTimeout(Timeout &t, Status sc);
/// Called by the Meta system once the reply has been recieved and processed
void setComplete();
const std::string _host; ///< The host being querried
Meta* _meta; ///< The Meta-server object which owns the query
long _queryNo; ///< The serial number of the query GET
Time::Stamp _stamp; ///< Time stamp of the request, to estimate ping to server
bool _complete; ///< Flag to indicate when the query is complete
};
} // of namespace
#endif
|