author | smxx |
Sun, 28 Mar 2010 18:26:31 +0000 | |
changeset 3139 | a075f5344796 |
parent 1066 | 1f1b3686a2b0 |
child 4976 | 088d40d8aba2 |
permissions | -rw-r--r-- |
184 | 1 |
/* |
1066 | 2 |
* Hedgewars, a free turn based strategy game |
486 | 3 |
* Copyright (c) 2006, 2007 Igor Ulyanov <iulyanov@gmail.com> |
184 | 4 |
* |
5 |
* This program is free software; you can redistribute it and/or modify |
|
6 |
* it under the terms of the GNU General Public License as published by |
|
7 |
* the Free Software Foundation; version 2 of the License |
|
8 |
* |
|
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU General Public License |
|
15 |
* along with this program; if not, write to the Free Software |
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
|
17 |
*/ |
|
18 |
||
19 |
#ifndef _TCPBASE_INCLUDED |
|
20 |
#define _TCPBASE_INCLUDED |
|
21 |
||
22 |
#include <QObject> |
|
23 |
#include <QTcpServer> |
|
24 |
#include <QTcpSocket> |
|
25 |
#include <QByteArray> |
|
26 |
#include <QString> |
|
27 |
#include <QDir> |
|
28 |
#include <QProcess> |
|
389 | 29 |
#include <QPointer> |
184 | 30 |
|
31 |
#include <QImage> |
|
32 |
||
33 |
#define MAXMSGCHARS 255 |
|
34 |
||
35 |
class TCPBase : public QObject |
|
36 |
{ |
|
37 |
Q_OBJECT |
|
389 | 38 |
|
184 | 39 |
public: |
40 |
TCPBase(bool demoMode); |
|
419
fdeed9718e6b
virtual destructors for tcpBase derived classes, readarray clear removed as unneeded
displacer
parents:
389
diff
changeset
|
41 |
virtual ~TCPBase(); |
184 | 42 |
|
43 |
signals: |
|
44 |
void isReadyNow(); |
|
45 |
||
46 |
protected: |
|
291 | 47 |
quint16 ipc_port; |
48 |
||
184 | 49 |
void Start(); |
50 |
||
51 |
QByteArray readbuffer; |
|
52 |
||
53 |
QByteArray toSendBuf; |
|
533 | 54 |
QByteArray demo; |
184 | 55 |
|
56 |
void SendIPC(const QByteArray & buf); |
|
57 |
void RawSendIPC(const QByteArray & buf); |
|
58 |
||
59 |
virtual QStringList setArguments()=0; |
|
60 |
virtual void onClientRead(); |
|
61 |
virtual void onClientDisconnect(); |
|
62 |
virtual void SendToClientFirst(); |
|
63 |
||
64 |
private: |
|
389 | 65 |
static QPointer<QTcpServer> IPCServer; |
185 | 66 |
|
184 | 67 |
bool m_isDemoMode; |
185 | 68 |
void RealStart(); |
389 | 69 |
QPointer<QTcpSocket> IPCSocket; |
184 | 70 |
|
71 |
private slots: |
|
72 |
void NewConnection(); |
|
73 |
void ClientDisconnect(); |
|
74 |
void ClientRead(); |
|
75 |
void StartProcessError(QProcess::ProcessError error); |
|
76 |
||
77 |
void tcpServerReady(); |
|
78 |
}; |
|
79 |
||
80 |
#endif // _TCPBASE_INCLUDED |