Server Class Reference

List of all members.

Public Types

enum  Response {
  RESPONSE_GOOD, RESPONSE_TIMEOUT, RESPONSE_WAIT, RESPONSE_BAD,
  RESPONSE_BANNED, RESPONSE_NO_RESPONSE_YET
}

Public Slots

bool refresh ()

Signals

void begunRefreshing (Server *server)
void updated (Server *server, int response)

Public Member Functions

 Server (const QHostAddress &address, unsigned short port)
virtual Binariesbinaries () const
 Creates an instance of Binaries's descendant class.
virtual QString engineName () const
void lookupHost ()
 Prompts the server to reverse resolve its address to a hostname.
const QHostAddress & address () const
QString addressWithPort () const
const QString & connectPassword () const
const QString & eMail () const
const DMFlagsgameFlags () const
const GameModegameMode () const
unsigned char gameSkill () const
virtual bool hasRcon () const
QString hostName (bool forceAddress=false) const
const QPixmap & icon () const
bool isBroadcastingToLAN () const
bool isBroadcastingToMaster () const
bool isCustom () const
bool isEmpty () const
bool isFull () const
bool isKnown () const
bool isLocked () const
bool isRefreshable () const
bool isSecured () const
bool isSetToDelete () const
const QString & iwadName () const
const QString & joinPassword () const
int lastResponse () const
const QString & map () const
const QStringList & mapsList () const
unsigned short maximumClients () const
unsigned short maximumPlayers () const
const QString & messageOfTheDay () const
virtual const GameCVarmodifier () const
const QString & name () const
int numFreeClientSlots () const
int numFreeJoinSlots () const
int numFreeSpectatorSlots () const
int numWads () const
unsigned int ping () const
const Playerplayer (int index) const
const PlayersListplayersList () const
unsigned short port () const
const QList< PWad > & pwads () const
bool randomMapRotation () const
virtual RConProtocolrcon ()
const QString & rconPassword () const
unsigned int score (int team=0) const
unsigned int scoreLimit () const
virtual QRgb teamColor (int team) const
virtual QString teamName (int team) const
unsigned short timeLeft () const
unsigned short timeLimit () const
const QString version () const
const PWadwad (int index) const
const QString & website () const
void setBroadcastToLAN (bool b)
void setBroadcastToMaster (bool b)
void setHostEmail (const QString &mail)
void setGameMode (const GameMode &gameMode)
void setMap (const QString &name)
void setMapList (const QStringList &maplist)
void setMaximumClients (unsigned short i)
void setMaximumPlayers (unsigned short i)
void setMOTD (const QString &message)
void setName (const QString &name)
void setPasswordConnect (const QString &str)
void setPasswordJoin (const QString &str)
void setPasswordRCon (const QString &str)
void setPort (unsigned short i)
void setRandomMapRotation (bool b)
void setSkill (unsigned char newSkill)
void setWebsite (const QString &site)
void setCustom (bool b)
void setToDelete (bool b)
virtual GameRunnergameRunner () const
 Creates an instance of GameRunner's derivative class.
void refreshStarts ()
void refreshStops (Response response)
Response readRefreshQueryResponse (QByteArray &data)
bool sendRefreshQuery (QUdpSocket *socket)
bool isRefreshing () const
virtual const EnginePluginplugin () const =0
virtual TooltipGeneratortooltipGenerator () const
 Creates an instance of TooltipGenerator.

Protected Slots

void setHostName (QHostInfo host)

Protected Member Functions

void clearDMFlags ()
void emitUpdated (int response)
virtual Response readRequest (QByteArray &data)=0
virtual bool sendRequest (QByteArray &data)=0

Protected Attributes

bool bDelete
bool bKnown
bool bPingIsSet
bool bSecureServer
bool broadcastToLAN
bool broadcastToMaster
GameMode currentGameMode
unsigned int currentPing
bool custom
DMFlags dmFlags
QString email
QString iwad
bool locked
QStringList mapList
QString mapName
bool mapRandomRotation
unsigned short maxClients
unsigned short maxPlayers
QString motd
QString passwordConnect
QString passwordJoin
QString passwordRCon
PlayersListplayers
Response response
unsigned int scores [MAX_TEAMS]
QString serverName
unsigned int serverScoreLimit
unsigned short serverTimeLeft
unsigned short serverTimeLimit
QString serverVersion
unsigned char skill
QList< PWadwads
QString webSite
QTime time

Static Protected Attributes

static QString teamNames []

Friends

class ServerPointer

Member Function Documentation

Binaries * Server::binaries (  )  const [virtual]

Creates an instance of Binaries's descendant class.

Created instance should be deleted manually by the programmer.

Returns:
A pointer to a new instance of Binaries's descendant (defined by a plugin)
void Server::emitUpdated ( int  response  )  [inline, protected]

Wrapper function to allow refresher to emit the updated signal.

QString Server::engineName (  )  const [virtual]

Returns name of the engine for this server, for example: "Skulltag". By default this returns name defined by the parent plugin itself, or "Undefined" string if there is no parent plugin.

GameRunner * Server::gameRunner (  )  const [virtual]

Creates an instance of GameRunner's derivative class.

Gets a pointer to a new instance of GameRunner's descendant (defined by a plugin). Created instance should be deleted manually by the programmer.

QString Server::hostName ( bool  forceAddress = false  )  const

Returns a string of either the ipaddress:port or hostname:port depending on if the hostname information has been retrieved, if reverse lookups is enabled, and the forceAddress parameter.

void Server::lookupHost (  ) 

Prompts the server to reverse resolve its address to a hostname.

The lookup will be performed asynchronously. When lookup is finished then updated() signal will be emitted.

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

This is supposed to return the plugin this Server belongs to. 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.

virtual Response Server::readRequest ( QByteArray &  data  )  [protected, pure virtual]

Reads response data.

Returns:
the resposne that should be emitted. Do NOT perform any signal emissions from within this functions. This is not thread safe and may lead to a crash.
bool Server::refresh (  )  [slot]

Updates the server data.

void Server::refreshStarts (  ) 

Called when server begins refreshing routine.

void Server::refreshStops ( Response  response  ) 

Called when server finishes refreshing routine.

bool Server::sendRefreshQuery ( QUdpSocket *  socket  ) 

Method called by the refreshing thread. Sends the query through refreshing thread socket.

Returns:
false if it's impossible to send the query (fail)
virtual bool Server::sendRequest ( QByteArray &  data  )  [protected, pure virtual]

Prepares challenge data.

Returns:
true on success and RESPONSE_GOOD signal should be emitted, false otherwise.
TooltipGenerator * Server::tooltipGenerator (  )  const [virtual]

Creates an instance of TooltipGenerator.

This can be replaced by a plugin to use a custom tooltip generator.

Returns:
Default behaviour returns default implementation of TooltipGenerator.
void Server::updated ( Server server,
int  response 
) [signal]

Emitted when a refresh has been completed. Be sure to check the response to see if anything has actually changed.

See also:
Response

Member Data Documentation

bool Server::bDelete [protected]

If this is true server will be deleted as soon as it finished working (refreshing). This should be safer than blatant `delete server` while server's thread is still running.

bool Server::bKnown [protected]

This should be set to true upon successful return from doRefresh(), and to false upon failure. setServers() protected slot handles this. Example usage: Skulltag servers can use this to update ping if the server responds with "wait before refreshing".

bool Server::bPingIsSet [protected]

Refresher sets this to false before calling the virtual readRequest() method. If this method sets this to true, Refresher will not modify the currentPing field assuming that readRequest() set currentPing to a correct value. If it remains false after the readRequest() call Doomseeker will use a global method to determine ping, which may be less accurate.

QString Server::teamNames [static, protected]
Initial value:
{
        "Blue",
        "Red",
        "Green",
        "Gold"
}

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