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

QHostAddress address () const
 Address of the master server. More...
 
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
 
unsigned short port () const
 Network port of the master server. More...
 
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

QHostAddress MasterClient::address ( ) const
protected

Address of the master server.

Definition at line 87 of file masterclient.cpp.

void MasterClient::clearServers ( )

Clears the server list.

Definition at line 92 of file masterclient.cpp.

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 immediately aborted.

Implemented in CustomServers.

void MasterClient::emptyServerList ( )
protected

Clears the server list; alias to clearServers().

Definition at line 115 of file masterclient.cpp.

QString MasterClient::engineName ( ) const

Extracts engine name from pluginInfo() if available.

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

Definition at line 120 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 97 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 129 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 134 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 nullptr. 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.

unsigned short MasterClient::port ( ) const
protected

Network port of the master server.

Definition at line 182 of file masterclient.cpp.

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 234 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 312 of file masterclient.cpp.

void MasterClient::registerNewServer ( ServerPtr  server)
protected

Registers new server with this MasterClient.

Definition at line 297 of file masterclient.cpp.

bool MasterClient::sendRequest ( QUdpSocket *  socket)

Sends request packet through socket.

Definition at line 319 of file masterclient.cpp.

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

Definition at line 337 of file masterclient.cpp.

void MasterClient::timeoutRefresh ( )
slot

Times the refreshing process out.

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

Definition at line 347 of file masterclient.cpp.

void MasterClient::timeoutRefreshEx ( )
protectedvirtual

Reimplement this for clean up purposes.

Definition at line 362 of file masterclient.cpp.


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