RConProtocol Class Reference

Remote console protocol interface. More...

#include <rconprotocol.h>

+ Inheritance diagram for RConProtocol:

Public Slots

void disconnectFromServer ()
 [Pure Virtual] Close connection with the server. More...
 
void sendCommand (const QString &cmd)
 [Pure Virtual] Send command to remote server. More...
 
void sendPassword (const QString &password)
 [Pure Virtual] Send remote console password. More...
 

Signals

void disconnected ()
 Emitted by implementation when connection with the remote server is closed. More...
 
void invalidPassword ()
 Emitted by implementation if remote console password is invalid. More...
 
void messageReceived (const QString &msg)
 Passes all messages from the remote server that should be displayed to the user. More...
 
void playerListUpdated ()
 Emitted by implementation everytime the list of players is modified. More...
 
void serverNameChanged (const QString &name)
 Emitted by implementation when server name changes. More...
 

Public Member Functions

bool isConnected () const
 Whether connection is established or not. More...
 
const QList< Player > & players () const
 List of players present on the server. More...
 

Protected Member Functions

 RConProtocol (ServerPtr server)
 
const QHostAddress & address () const
 Address of the server to which this remote console should connect. More...
 
QList< Player > & playersMutable ()
 Accessor to players list that allows modification. More...
 
quint16 port () const
 Port of the server to which this remote console should connect. More...
 
void setConnected (bool b)
 Set this to true when connection is successfully established, set to false upon disconnect. More...
 
QUdpSocket & socket ()
 UDP socket that can be used to communicate with remote server. More...
 

Friends

class Server
 

Detailed Description

Remote console protocol interface.

Doomseeker can be used to administrate remote server through the server's remote console protocol. Implementation, if provided, is returned through an instance of Server that also needs to be implemented by the plugin.

Implementation and communication with Doomseeker.

A working example of implementation is provided in Zandronum plugin source code.

Plugin implementation needs to provide all [Pure Virtual] methods. Doomseeker starts by asking user for RCon password. At this point RConProtocol isn't even called yet. Once user provides a password, the first call to sendPassword() is made. It's at this point that the RConProtocol implementation should first establish connection with the server, interpret any responses and send the password. It's up to the plugin to determine when setConnected() should be called and what conditions mean that it should be set to true or false. All messages that should be displayed by Doomseeker should be emitted through messageReceived() signal. This also includes important error messages such as "You've been banned from this server." If password specified by the user is invalid, an invalidPassword() signal should be emitted so that Doomseeker can ask the user for correction. When connection is lost or closed, a disconnected() signal should be emitted. This signal should also be emitted after a call to disconnectFromServer(), but only after the plugin is certain that the connection is in fact closed. This allows Doomseeker to close connection gracefully. Keep in mind that Doomseeker can also call disconnectFromServer() even if it already knows that isConnected() returns false. In this case it's also expected that the plugin will emit disconnected() signal, even if that's the only thing that it'll do in its implementation of disconnectFromServer(). Each command input by the user is sent through sendCommand() slot.

There are also some utilities that allow Doomseeker to update certain parts of display. For example, whenever server name changes (or is first made known), the serverNameChanged() signal should be emitted. Similar goes for player list which has corresponding playerListUpdated() signal, upon which Doomseeker accesses players() list.

Definition at line 79 of file rconprotocol.h.

Member Function Documentation

const QHostAddress& RConProtocol::address ( ) const
protected

Address of the server to which this remote console should connect.

void RConProtocol::disconnected ( )
signal

Emitted by implementation when connection with the remote server is closed.

void RConProtocol::disconnectFromServer ( )
slot

[Pure Virtual] Close connection with the server.

Disconnects remote console and sets isConnected() state to false.

void RConProtocol::invalidPassword ( )
signal

Emitted by implementation if remote console password is invalid.

This ought to be emitted after a call to sendPassword() if that call fails.

bool RConProtocol::isConnected ( ) const

Whether connection is established or not.

This is set manually by the plugin implementation through setConnected() setter. It means that plugin decides on its own what it means "to be connected" and when exactly the connection is established.

Definition at line 76 of file rconprotocol.cpp.

void RConProtocol::messageReceived ( const QString &  msg)
signal

Passes all messages from the remote server that should be displayed to the user.

void RConProtocol::playerListUpdated ( )
signal

Emitted by implementation everytime the list of players is modified.

This signal is used to refresh players list. Emit it whenever you modify players list through playersMutable() accessor.

const QList< Player > & RConProtocol::players ( ) const

List of players present on the server.

This is a read-only accessor. It's used by Doomseeker to display players list. It's accessed whenever the playerListUpdated() signal is emitted. List of players can be modified through playersMutable() accessor.

Definition at line 86 of file rconprotocol.cpp.

QList< Player > & RConProtocol::playersMutable ( )
protected

Accessor to players list that allows modification.

Implementation should use this accessor to update players list. Everytime modification is made, a playerListUpdated() signal should be emitted.

Definition at line 91 of file rconprotocol.cpp.

quint16 RConProtocol::port ( ) const
protected

Port of the server to which this remote console should connect.

Definition at line 81 of file rconprotocol.cpp.

void RConProtocol::sendCommand ( const QString &  cmd)
slot

[Pure Virtual] Send command to remote server.

Command is provided through Doomseeker user interface. It can be literally anything, and if the plugin needs to perform any special parsing, it needs to do so on its own.

void RConProtocol::sendPassword ( const QString &  password)
slot

[Pure Virtual] Send remote console password.

Password is provided through Doomseeker user interface.

void RConProtocol::serverNameChanged ( const QString &  name)
signal

Emitted by implementation when server name changes.

This signal is used to refresh remote console title.

void RConProtocol::setConnected ( bool  b)
protected

Set this to true when connection is successfully established, set to false upon disconnect.

Definition at line 108 of file rconprotocol.cpp.

QUdpSocket & RConProtocol::socket ( )
protected

UDP socket that can be used to communicate with remote server.

This socket is not connected in any way. It's provided as a mere convenience. RConProtocol constructor calls bind() on that socket and its destructor calls close(). Everything else needs to be programmed by the implementation. If remote console for your implementation uses a different means of communication (TCP, HTTP), you may ignore this socket and implement your own.

Definition at line 113 of file rconprotocol.cpp.


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