rconprotocol.h
1 //------------------------------------------------------------------------------
2 // rconprotocol.h
3 //------------------------------------------------------------------------------
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library 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 GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; 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 Braden "Blzut3" Obrzut <admin@maniacsvault.net>
22 //------------------------------------------------------------------------------
23 #ifndef __RCON_PROTOCOL_H_
24 #define __RCON_PROTOCOL_H_
25 
26 #include "dptr.h"
27 #include "player.h"
28 #include "serverapi/polymorphism.h"
29 #include "serverapi/serverptr.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() override;
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 
169 
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