author | unc0rr |
Fri, 25 Jul 2008 20:57:36 +0000 | |
changeset 1101 | ec4cdf8a072f |
parent 1082 | 596b1dcdc1df |
child 1302 | 4290ba4a14ca |
permissions | -rw-r--r-- |
420
6cdfc07dceed
netserver and netonnectedclient splited to different files
displacer
parents:
diff
changeset
|
1 |
/* |
1066 | 2 |
* Hedgewars, a free turn based strategy game |
420
6cdfc07dceed
netserver and netonnectedclient splited to different files
displacer
parents:
diff
changeset
|
3 |
* Copyright (c) 2006 Igor Ulyanov <iulyanov@gmail.com> |
6cdfc07dceed
netserver and netonnectedclient splited to different files
displacer
parents:
diff
changeset
|
4 |
* |
6cdfc07dceed
netserver and netonnectedclient splited to different files
displacer
parents:
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
6cdfc07dceed
netserver and netonnectedclient splited to different files
displacer
parents:
diff
changeset
|
6 |
* it under the terms of the GNU General Public License as published by |
6cdfc07dceed
netserver and netonnectedclient splited to different files
displacer
parents:
diff
changeset
|
7 |
* the Free Software Foundation; version 2 of the License |
6cdfc07dceed
netserver and netonnectedclient splited to different files
displacer
parents:
diff
changeset
|
8 |
* |
6cdfc07dceed
netserver and netonnectedclient splited to different files
displacer
parents:
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
6cdfc07dceed
netserver and netonnectedclient splited to different files
displacer
parents:
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
6cdfc07dceed
netserver and netonnectedclient splited to different files
displacer
parents:
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
6cdfc07dceed
netserver and netonnectedclient splited to different files
displacer
parents:
diff
changeset
|
12 |
* GNU General Public License for more details. |
6cdfc07dceed
netserver and netonnectedclient splited to different files
displacer
parents:
diff
changeset
|
13 |
* |
6cdfc07dceed
netserver and netonnectedclient splited to different files
displacer
parents:
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
6cdfc07dceed
netserver and netonnectedclient splited to different files
displacer
parents:
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
6cdfc07dceed
netserver and netonnectedclient splited to different files
displacer
parents:
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
6cdfc07dceed
netserver and netonnectedclient splited to different files
displacer
parents:
diff
changeset
|
17 |
*/ |
6cdfc07dceed
netserver and netonnectedclient splited to different files
displacer
parents:
diff
changeset
|
18 |
|
6cdfc07dceed
netserver and netonnectedclient splited to different files
displacer
parents:
diff
changeset
|
19 |
#ifndef _HET_CONNECTEDCLIENT_INCLUDED |
6cdfc07dceed
netserver and netonnectedclient splited to different files
displacer
parents:
diff
changeset
|
20 |
#define _HET_CONNECTEDCLIENT_INCLUDED |
6cdfc07dceed
netserver and netonnectedclient splited to different files
displacer
parents:
diff
changeset
|
21 |
|
6cdfc07dceed
netserver and netonnectedclient splited to different files
displacer
parents:
diff
changeset
|
22 |
#include <QObject> |
6cdfc07dceed
netserver and netonnectedclient splited to different files
displacer
parents:
diff
changeset
|
23 |
#include <QList> |
6cdfc07dceed
netserver and netonnectedclient splited to different files
displacer
parents:
diff
changeset
|
24 |
#include <QMap> |
1082 | 25 |
#include <QStringList> |
420
6cdfc07dceed
netserver and netonnectedclient splited to different files
displacer
parents:
diff
changeset
|
26 |
|
6cdfc07dceed
netserver and netonnectedclient splited to different files
displacer
parents:
diff
changeset
|
27 |
class HWNetServer; |
6cdfc07dceed
netserver and netonnectedclient splited to different files
displacer
parents:
diff
changeset
|
28 |
class QTcpSocket; |
6cdfc07dceed
netserver and netonnectedclient splited to different files
displacer
parents:
diff
changeset
|
29 |
class QTcpServer; |
6cdfc07dceed
netserver and netonnectedclient splited to different files
displacer
parents:
diff
changeset
|
30 |
|
6cdfc07dceed
netserver and netonnectedclient splited to different files
displacer
parents:
diff
changeset
|
31 |
class HWConnectedClient : public QObject |
6cdfc07dceed
netserver and netonnectedclient splited to different files
displacer
parents:
diff
changeset
|
32 |
{ |
6cdfc07dceed
netserver and netonnectedclient splited to different files
displacer
parents:
diff
changeset
|
33 |
Q_OBJECT |
6cdfc07dceed
netserver and netonnectedclient splited to different files
displacer
parents:
diff
changeset
|
34 |
|
6cdfc07dceed
netserver and netonnectedclient splited to different files
displacer
parents:
diff
changeset
|
35 |
friend class HWNetServer; |
6cdfc07dceed
netserver and netonnectedclient splited to different files
displacer
parents:
diff
changeset
|
36 |
|
6cdfc07dceed
netserver and netonnectedclient splited to different files
displacer
parents:
diff
changeset
|
37 |
private: |
6cdfc07dceed
netserver and netonnectedclient splited to different files
displacer
parents:
diff
changeset
|
38 |
HWConnectedClient(HWNetServer* hwserver, QTcpSocket* client); |
6cdfc07dceed
netserver and netonnectedclient splited to different files
displacer
parents:
diff
changeset
|
39 |
~HWConnectedClient(); |
6cdfc07dceed
netserver and netonnectedclient splited to different files
displacer
parents:
diff
changeset
|
40 |
QString getClientNick() const; |
6cdfc07dceed
netserver and netonnectedclient splited to different files
displacer
parents:
diff
changeset
|
41 |
|
6cdfc07dceed
netserver and netonnectedclient splited to different files
displacer
parents:
diff
changeset
|
42 |
QList<QStringList> getTeamNames() const; |
6cdfc07dceed
netserver and netonnectedclient splited to different files
displacer
parents:
diff
changeset
|
43 |
class NoTeamNameException{}; |
6cdfc07dceed
netserver and netonnectedclient splited to different files
displacer
parents:
diff
changeset
|
44 |
bool isReady() const; |
6cdfc07dceed
netserver and netonnectedclient splited to different files
displacer
parents:
diff
changeset
|
45 |
|
6cdfc07dceed
netserver and netonnectedclient splited to different files
displacer
parents:
diff
changeset
|
46 |
QString getHedgehogsDescription() const; |
6cdfc07dceed
netserver and netonnectedclient splited to different files
displacer
parents:
diff
changeset
|
47 |
|
6cdfc07dceed
netserver and netonnectedclient splited to different files
displacer
parents:
diff
changeset
|
48 |
bool readyToStart; |
6cdfc07dceed
netserver and netonnectedclient splited to different files
displacer
parents:
diff
changeset
|
49 |
QList<QStringList> m_teamsCfg; // TeamName - hhs |
6cdfc07dceed
netserver and netonnectedclient splited to different files
displacer
parents:
diff
changeset
|
50 |
class ShouldDisconnectException {}; |
6cdfc07dceed
netserver and netonnectedclient splited to different files
displacer
parents:
diff
changeset
|
51 |
|
6cdfc07dceed
netserver and netonnectedclient splited to different files
displacer
parents:
diff
changeset
|
52 |
QString client_nick; |
1082 | 53 |
void ParseCmd(const QStringList & lst); |
420
6cdfc07dceed
netserver and netonnectedclient splited to different files
displacer
parents:
diff
changeset
|
54 |
unsigned int removeTeam(const QString& tname); // returns netID |
6cdfc07dceed
netserver and netonnectedclient splited to different files
displacer
parents:
diff
changeset
|
55 |
|
6cdfc07dceed
netserver and netonnectedclient splited to different files
displacer
parents:
diff
changeset
|
56 |
HWNetServer* m_hwserver; |
6cdfc07dceed
netserver and netonnectedclient splited to different files
displacer
parents:
diff
changeset
|
57 |
QTcpSocket* m_client; |
6cdfc07dceed
netserver and netonnectedclient splited to different files
displacer
parents:
diff
changeset
|
58 |
|
6cdfc07dceed
netserver and netonnectedclient splited to different files
displacer
parents:
diff
changeset
|
59 |
void RawSendNet(const QString & buf); |
6cdfc07dceed
netserver and netonnectedclient splited to different files
displacer
parents:
diff
changeset
|
60 |
void RawSendNet(const QByteArray & buf); |
6cdfc07dceed
netserver and netonnectedclient splited to different files
displacer
parents:
diff
changeset
|
61 |
|
1082 | 62 |
QStringList cmdbuf; |
420
6cdfc07dceed
netserver and netonnectedclient splited to different files
displacer
parents:
diff
changeset
|
63 |
|
6cdfc07dceed
netserver and netonnectedclient splited to different files
displacer
parents:
diff
changeset
|
64 |
signals: |
6cdfc07dceed
netserver and netonnectedclient splited to different files
displacer
parents:
diff
changeset
|
65 |
void HWClientDisconnected(HWConnectedClient* client); |
6cdfc07dceed
netserver and netonnectedclient splited to different files
displacer
parents:
diff
changeset
|
66 |
|
6cdfc07dceed
netserver and netonnectedclient splited to different files
displacer
parents:
diff
changeset
|
67 |
private slots: |
6cdfc07dceed
netserver and netonnectedclient splited to different files
displacer
parents:
diff
changeset
|
68 |
void ClientRead(); |
6cdfc07dceed
netserver and netonnectedclient splited to different files
displacer
parents:
diff
changeset
|
69 |
void ClientDisconnect(); |
6cdfc07dceed
netserver and netonnectedclient splited to different files
displacer
parents:
diff
changeset
|
70 |
}; |
6cdfc07dceed
netserver and netonnectedclient splited to different files
displacer
parents:
diff
changeset
|
71 |
|
6cdfc07dceed
netserver and netonnectedclient splited to different files
displacer
parents:
diff
changeset
|
72 |
#endif // _HET_CONNECTEDCLIENT_INCLUDED |