CustomServers Class Reference

#include <customservers.h>

+ Inheritance diagram for CustomServers:

Public Member Functions

const EnginePluginplugin () const
 
void readConfig (QObject *receiver, const char *slotUpdated, const char *slotBegunRefreshing)
 
void refreshStarts ()
 
void setServers (const QList< CustomServerInfo > &csiList, QObject *receiver, const char *slotUpdated, const char *slotBegunRefreshing)
 
- Public Member Functions inherited from MasterClient
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
 
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 ()
 

Static Public Member Functions

static void decodeConfigEntries (const QString &str, QList< CustomServerInfo > &outCustomServerInfoList)
 

Protected Member Functions

QByteArray createServerListRequest ()
 Produce contents of server list request packet that is sent to the master server. More...
 
Response readMasterResponse (const QByteArray &data)
 Called to read and analyze the response from the MasterServer. More...
 
- Protected Member Functions inherited from MasterClient
void emptyServerList ()
 
QString masterBanHelp_default () const
 
 POLYMORPHIC_SETTER_DECLARE_CONST (QString, MasterClient, masterBanHelp,())
 
bool preparePacketCache (bool write)
 
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...
 

Additional Inherited Members

- Public Types inherited from MasterClient
enum  Response {
  RESPONSE_GOOD, RESPONSE_TIMEOUT, RESPONSE_WAIT, RESPONSE_BAD,
  RESPONSE_BANNED, RESPONSE_NO_RESPONSE_YET, RESPONSE_PENDING, RESPONSE_REPLY,
  RESPONSE_OLD
}
 
- Public Slots inherited from MasterClient
void setEnabled (bool b)
 
void timeoutRefresh ()
 Times the refreshing process out. More...
 
- Signals inherited from MasterClient
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...
 

Detailed Description

A 'fake' master server that is used to handle custom servers from various engines.

Definition at line 48 of file customservers.h.

Member Function Documentation

QByteArray CustomServers::createServerListRequest ( )
inlineprotectedvirtual

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.

Implements MasterClient.

Definition at line 96 of file customservers.h.

void CustomServers::decodeConfigEntries ( const QString &  str,
QList< CustomServerInfo > &  outCustomServerInfoList 
)
static

Reads data in format (<engine_name>;<host_name>;<port>);(...)... and splits it to a list of CustomServerInfo objects. If a server for unknown engine is found it will be appended anyway but the CustomServerInfo::engineIndex will be set to a negative value.

Parameters
str- concatenated string in required format
Returns
list of custom servers

Definition at line 32 of file customservers.cpp.

const EnginePlugin* CustomServers::plugin ( ) const
inlinevirtual

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.

Implements MasterClient.

Definition at line 66 of file customservers.h.

void CustomServers::readConfig ( QObject *  receiver,
const char *  slotUpdated,
const char *  slotBegunRefreshing 
)

Convenience method - tries to read config seeking for "CustomServers" entry, decode it and launch setServers() method.

Parameters
receiver- object to receive server signals
slotUpdated- slot to receive Server::updated signals
slotBegunRefreshing- slot to receive Server::begunRefreshing signals

Definition at line 86 of file customservers.cpp.

Response CustomServers::readMasterResponse ( const QByteArray &  data)
inlineprotectedvirtual

Called to read and analyze the response from the MasterServer.

Implements MasterClient.

Definition at line 97 of file customservers.h.

void CustomServers::refreshStarts ( )
inlinevirtual

Since this is not required here (there's no real master to refresh) this does nothing.

Reimplemented from MasterClient.

Definition at line 81 of file customservers.h.

void CustomServers::setServers ( const QList< CustomServerInfo > &  csiList,
QObject *  receiver,
const char *  slotUpdated,
const char *  slotBegunRefreshing 
)

Sets a list of custom servers.

Parameters
csiList- list of custom servers. If element's engineIndex is < 0 the element is discarded. Also the element will be discarded if it's hostname cannot be resolved.
receiver- object to receive server signals
slotUpdated- slot to receive Server::updated signals
slotBegunRefreshing- slot to receive Server::begunRefreshing signals

Definition at line 92 of file customservers.cpp.


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