MasterClient Class Reference

#include <masterclient.h>

Inheritance diagram for MasterClient:
CustomServers MasterManager

List of all members.

Public Slots

virtual void refresh ()
void setEnabled (bool b)
void timeoutRefresh ()
 Times the refreshing process out.

Signals

void listUpdated ()
void message (const QString &title, const QString &content, bool isError)
void messageImportant (const Message &message)
 Signal used to forward important message to Doomseeker.
void newServerBatchReceived (const QList< Server * > &servers)
 Emit this signal each time a new batch of servers is received.

Public Member Functions

bool hasServer (const Server *)
bool isAddressDataCorrect (const QHostAddress &address, unsigned short port)
 Returns true if the passed address:port is the same as this master server's.
bool isEnabled () const
bool isTimeouted () const
int numPlayers () const
int numServers () const
Serveroperator[] (int index) const
virtual const EnginePluginplugin () const =0
void pushPacketToCache (QByteArray &data)
void resetPacketCaching ()
virtual bool readMasterResponse (QByteArray &data)=0
 Called to read and analyze the response from the MasterServer.
virtual bool readMasterResponse (QHostAddress &address, unsigned short port, QByteArray &data)
 Reads master response only if address and port are of this server.
QList< Server * > & serverList ()
const QList< Server * > & serverList () const
void updateAddress ()

Static Public Attributes

static QUdpSocket * pGlobalUdpSocket = NULL
 Generic Doomseeker's socket used for network communication.

Protected Member Functions

void emptyServerList ()
QString engineName () const
 Extracts engine name from pluginInfo() if available.
virtual bool getServerListRequest (QByteArray &data)=0
 Method that is supposed to produce the contents of server list request packet that is sent to the master server.
void notifyBanned ()
 Informs the user that they have been banned from the master server.
void notifyDelay ()
 Tells the user that the master server will not respond to their query becuase they tried to refresh too quickly.
void notifyError ()
 Tells the user that the master server returned a bad response.
void notifyUpdate ()
 Tells the user they need to update since the protocol is too old.
bool preparePacketCache (bool write)
void readPacketCache ()
virtual void timeoutRefreshEx ()
 Reimplement this for clean up purposes.

Protected Attributes

QHostAddress address
bool bTimeouted
 Indicates that the server has timeouted recently.
bool enabled
unsigned short port
QList< Server * > servers
QFile * cache

Detailed Description

Abstract class base for all MasterClients. This is expected to fetch a list of IP addresses which will be turned into Servers.


Member Function Documentation

void MasterClient::emptyServerList (  )  [protected]

Clears the server list.

QString MasterClient::engineName (  )  const [protected]

Extracts engine name from pluginInfo() if available.

Returns:
If pluginInfo() is NULL then this returns an empty string.
virtual bool MasterClient::getServerListRequest ( QByteArray &  data  )  [protected, pure virtual]

Method that is supposed to produce the contents of server list request packet that is sent to the master server.

Returns:
If false is returned refreshing of this master server is immediatelly aborted.

Implemented in CustomServers, and MasterManager.

bool MasterClient::isEnabled (  )  const [inline]

Serves as an informative role for MasterManager. If the master client is disabled, master manager will omit it during the refresh.

void MasterClient::message ( const QString &  title,
const QString &  content,
bool  isError 
) [signal]

Plugins may use this to make Doomseeker display custom messages. Messages are dumped into the log.

void MasterClient::messageImportant ( const Message message  )  [signal]

Signal used to forward important message to Doomseeker.

Important messages will be treated differently by Doomseeker than regular ones thrown by the message() signal. Doomseeker will display them in a location that will ensure that users see this message.

Example use: notify user that they have been banned from the master server.

void MasterClient::newServerBatchReceived ( const QList< Server * > &  servers  )  [signal]

Emit this signal each time a new batch of servers is received.

This signal should be called by the plugin after the response packet delivered to readMasterResponse() is processed. Master servers that send their response in multiple packets should be handled nicely by this.

virtual const EnginePlugin* MasterClient::plugin (  )  const [pure virtual]

This is supposed to return the plugin this MasterClient belongs to. If it doesn't belong to any plugin then return NULL. New instances of EnginePlugin shouldn't be created here. Instead each plugin should keep a global instance of EnginePlugin (singleton?) and a pointer to this instance should be returned.

Implemented in CustomServers, and MasterManager.

bool MasterClient::readMasterResponse ( QHostAddress &  address,
unsigned short  port,
QByteArray &  data 
) [virtual]

Reads master response only if address and port are of this server.

Reimplemented by MasterManager.

Reimplemented in MasterManager.

virtual bool MasterClient::readMasterResponse ( QByteArray &  data  )  [pure virtual]

Called to read and analyze the response from the MasterServer.

Returns:
If false is returned refreshing of this master server is immediatelly aborted.

Implemented in CustomServers, and MasterManager.

void MasterClient::refresh (  )  [virtual, slot]

Requests an updated server list from the master.

This function is virtual since MasterManager overrides it.

Reimplemented in CustomServers, and MasterManager.

void MasterClient::setEnabled ( bool  b  )  [inline, slot]
See also:
isEnabled()
void MasterClient::timeoutRefresh (  )  [slot]

Times the refreshing process out.

This calls timeoutRefreshEx() and then emits listUpdated() signal.


Member Data Documentation

bool MasterClient::bTimeouted [protected]

Indicates that the server has timeouted recently.

This is reset to false by refresh() and set to true by timeoutRefresh(). If you reimplement refresh() please remember to set this to false.

QUdpSocket * MasterClient::pGlobalUdpSocket = NULL [static]

Generic Doomseeker's socket used for network communication.

If this is not NULL plugins may use this socket to send UDP packets. In fact the default implementation of MasterClient::refresh() method will use this socket in order to send the challenge data. In this case any responses that arrive on this socket will automatically be redirected to appropriate master client instance by the Doomseeker's Refreshing thread.

If engine requires a customized way to obtain the server list it must be implemented within the plugin itself.


The documentation for this class was generated from the following files: