rconprotocol.h
1 //------------------------------------------------------------------------------
2 // rconprotocol.h
3 //------------------------------------------------------------------------------
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 // 02110-1301, USA.
19 //
20 //------------------------------------------------------------------------------
21 // Copyright (C) 2010 "Blzut3" <admin@maniacsvault.net>
22 //------------------------------------------------------------------------------
23 #ifndef __RCON_PROTOCOL_H_
24 #define __RCON_PROTOCOL_H_
25 
26 #include "serverapi/polymorphism.h"
27 #include "serverapi/serverptr.h"
28 #include "dptr.h"
29 #include "player.h"
30 #include <QThread>
31 #include <QUdpSocket>
32 
79 class MAIN_EXPORT RConProtocol : public QObject
80 {
81  Q_OBJECT
82 
83  public:
84  virtual ~RConProtocol();
85 
94  bool isConnected() const;
103  const QList<Player> &players() const;
104 
105  public slots:
111  void disconnectFromServer();
119  void sendCommand(const QString &cmd);
125  void sendPassword(const QString &password);
126 
127  signals:
132  void disconnected();
140  void invalidPassword();
145  void messageReceived(const QString &msg);
154  void playerListUpdated();
160  void serverNameChanged(const QString &name);
161 
162  protected:
163  RConProtocol(ServerPtr server);
164 
165  POLYMORPHIC_SETTER_DECLARE(void, RConProtocol, disconnectFromServer, ());
166  POLYMORPHIC_SETTER_DECLARE(void, RConProtocol, sendCommand, (const QString &cmd));
167  POLYMORPHIC_SETTER_DECLARE(void, RConProtocol, sendPassword, (const QString &password));
168 
173  const QHostAddress &address() const;
178  quint16 port() const;
186  QList<Player> &playersMutable();
199  QUdpSocket &socket();
204  void setConnected(bool b);
205 
206  friend class Server;
207 
208  private:
210 
211  void disconnectFromServer_default();
212  void sendCommand_default(const QString &cmd);
213  void sendPassword_default(const QString &password);
214 };
215 
216 #endif
A representation of a server for a given game.
Definition: server.h:93
Remote console protocol interface.
Definition: rconprotocol.h:79