1 | /*************************************************************************** |
2 | * KBlocks, a falling blocks game for KDE * |
3 | * Copyright (C) 2010 Zhongjie Cai <squall.leonhart.cai@gmail.com> * |
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; either version 2 of the License, or * |
8 | * (at your option) any later version. * |
9 | ***************************************************************************/ |
10 | #ifndef KBLOCKSNETCLIENT_H |
11 | #define KBLOCKSNETCLIENT_H |
12 | |
13 | #include <QObject> |
14 | #include <QUdpSocket> |
15 | #include <QString> |
16 | #include <QByteArray> |
17 | |
18 | class KBlocksNetClient : public QObject |
19 | { |
20 | Q_OBJECT |
21 | |
22 | public: |
23 | KBlocksNetClient(const QString& remoteIP, quint16 localPort); |
24 | ~KBlocksNetClient(); |
25 | |
26 | public: |
27 | int sendData(int count, char * data); |
28 | int recvData(int count, char * data); |
29 | |
30 | signals: |
31 | void dataArrived(int size); |
32 | |
33 | private: |
34 | bool parseIPString(const QString& input, QHostAddress * ip, quint16 * port); |
35 | |
36 | private slots: |
37 | void receivedData(); |
38 | |
39 | private: |
40 | QUdpSocket * mpClientSocket; |
41 | |
42 | QHostAddress mLocalAddress; |
43 | quint16 mLocalPort; |
44 | |
45 | QHostAddress mRemoteAddress; |
46 | quint16 mRemotePort; |
47 | }; |
48 | |
49 | #endif |
50 | |
51 | |