diff options
Diffstat (limited to '')
-rw-r--r-- | src/gatscon/clientthread.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/gatscon/clientthread.cpp b/src/gatscon/clientthread.cpp new file mode 100644 index 0000000..b1dc4d0 --- /dev/null +++ b/src/gatscon/clientthread.cpp | |||
@@ -0,0 +1,38 @@ | |||
1 | #include "clientthread.h" | ||
2 | |||
3 | #include <bu/tcpsocket.h> | ||
4 | |||
5 | ClientThread::ClientThread( QObject *pParent, const QByteArray &baHost, | ||
6 | int iPort ) : | ||
7 | QThread( pParent ), | ||
8 | baHost( baHost ), | ||
9 | iPort( iPort ), | ||
10 | gsCli( ssCli ) | ||
11 | { | ||
12 | } | ||
13 | |||
14 | ClientThread::~ClientThread() | ||
15 | { | ||
16 | } | ||
17 | |||
18 | void ClientThread::send( Gats::Object *pObj ) | ||
19 | { | ||
20 | gsCli.writeObject( pObj ); | ||
21 | } | ||
22 | |||
23 | void ClientThread::run() | ||
24 | { | ||
25 | ssCli.setStream( | ||
26 | new Bu::TcpSocket( baHost.constData(), iPort ) | ||
27 | ); | ||
28 | |||
29 | while( !ssCli.isEos() ) | ||
30 | { | ||
31 | Gats::Object *pObj = gsCli.readObject(); | ||
32 | if( pObj == NULL ) | ||
33 | break; | ||
34 | |||
35 | emit recv( pObj ); | ||
36 | } | ||
37 | } | ||
38 | |||