MasterClient Class Referenceabstract

Abstract base for all MasterClients. More...

#include <masterclient.h>

+ Inheritance diagram for MasterClient:

Public Types

enum  Response {
  RESPONSE_GOOD, RESPONSE_TIMEOUT, RESPONSE_WAIT, RESPONSE_BAD,
  RESPONSE_BANNED, RESPONSE_NO_RESPONSE_YET, RESPONSE_PENDING, RESPONSE_REPLY,
  RESPONSE_OLD
}
 

Public Slots

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

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. More...
 

Public Member Functions

void clearServers ()
 
QString engineName () const
 Extracts engine name from pluginInfo() if available. More...
 
bool isAddressSame (const QHostAddress &address, unsigned short port) const
 Returns true if the passed address:port is the same as this master server's. More...
 
bool isEnabled () const
 
bool isTimeouted () const
 Indicates that the server has timeouted recently. More...
 
QString masterBanHelp () const
 [Virtual] Help message displayed to the user when ban is detected. More...
 
void notifyResponse (Response response)
 
int numPlayers () const
 
int numServers () const
 
ServerPtr operator[] (int index) const
 
virtual const EnginePluginplugin () const =0
 
void pushPacketToCache (const QByteArray &data)
 
Response readResponse (const QByteArray &data)
 Calls readMasterResponse and handles packet caching. More...
 
void resetPacketCaching ()
 
bool sendRequest (QUdpSocket *socket)
 Sends request packet through socket. More...
 
const QList< ServerPtr > & servers () const
 
void updateAddress ()
 

Protected Member Functions

virtual QByteArray createServerListRequest ()=0
 Produce contents of server list request packet that is sent to the master server. More...
 
void emptyServerList ()
 
QString masterBanHelp_default () const
 
 POLYMORPHIC_SETTER_DECLARE_CONST (QString, MasterClient, masterBanHelp,())
 
bool preparePacketCache (bool write)
 
virtual Response readMasterResponse (const QByteArray &data)=0
 Called to read and analyze the response from the MasterServer. More...
 
void readPacketCache ()
 
void registerNewServer (ServerPtr server)
 Registers new server with this MasterClient. More...
 
void setTimeouted (bool b)
 
virtual void timeoutRefreshEx ()
 Reimplement this for clean up purposes. More...
 

Detailed Description

Abstract base for all MasterClients.

This is expected to fetch a list of IP addresses which will be turned into Servers.

Definition at line 49 of file masterclient.h.

Member Function Documentation

virtual QByteArray MasterClient::createServerListRequest ( )
protectedpure virtual

Produce contents of server list request packet that is sent to the master server.

Returns
If empty array is returned refreshing of this master server is immediatelly aborted.

Implemented in CustomServers.

void MasterClient::emptyServerList ( )
protected

Clears the server list.

Definition at line 110 of file masterclient.cpp.

QString MasterClient::engineName ( ) const

Extracts engine name from pluginInfo() if available.

Returns
If pluginInfo() is NULL then this returns an empty string.

Definition at line 119 of file masterclient.cpp.

bool MasterClient::isAddressSame ( const QHostAddress &  address,
unsigned short  port 
) const

Returns true if the passed address:port is the same as this master server's.

Definition at line 92 of file masterclient.cpp.

bool MasterClient::isEnabled ( ) const

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

Definition at line 128 of file masterclient.cpp.

bool MasterClient::isTimeouted ( ) const

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.

Definition at line 133 of file masterclient.cpp.

QString MasterClient::masterBanHelp ( ) const

[Virtual] Help message displayed to the user when ban is detected.

Doomseeker displays a "you're banned from this master server" message when RESPONSE_BANNED is returned by readResponse(). By redefining this method, your plugin may show additional help message next to the usual one. Normally, you'd have this return some kind of staff contact info. Basic HTML is supported in the display.

Default implementation returns an empty string.

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.

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.

virtual Response MasterClient::readMasterResponse ( const QByteArray &  data)
protectedpure virtual

Called to read and analyze the response from the MasterServer.

Implemented in CustomServers.

MasterClient::Response MasterClient::readResponse ( const QByteArray &  data)

Calls readMasterResponse and handles packet caching.

Definition at line 241 of file masterclient.cpp.

void MasterClient::refreshStarts ( )
virtualslot

Requests an updated server list from the master.

This function is virtual since MasterManager overrides it.

Reimplemented in CustomServers.

Definition at line 319 of file masterclient.cpp.

void MasterClient::registerNewServer ( ServerPtr  server)
protected

Registers new server with this MasterClient.

Definition at line 304 of file masterclient.cpp.

bool MasterClient::sendRequest ( QUdpSocket *  socket)

Sends request packet through socket.

Definition at line 326 of file masterclient.cpp.

void MasterClient::setEnabled ( bool  b)
slot
See Also
isEnabled()

Definition at line 344 of file masterclient.cpp.

void MasterClient::timeoutRefresh ( )
slot

Times the refreshing process out.

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

Definition at line 354 of file masterclient.cpp.

void MasterClient::timeoutRefreshEx ( )
protectedvirtual

Reimplement this for clean up purposes.

Definition at line 369 of file masterclient.cpp.


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