diff options
Diffstat (limited to 'c++-qt/tests/echo/mainwnd.cpp')
-rw-r--r-- | c++-qt/tests/echo/mainwnd.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/c++-qt/tests/echo/mainwnd.cpp b/c++-qt/tests/echo/mainwnd.cpp new file mode 100644 index 0000000..4b90421 --- /dev/null +++ b/c++-qt/tests/echo/mainwnd.cpp | |||
@@ -0,0 +1,30 @@ | |||
1 | #include "mainwnd.h" | ||
2 | |||
3 | MainWnd::MainWnd() | ||
4 | { | ||
5 | pSrv = new QTcpServer( this ); | ||
6 | connect( pSrv, SIGNAL(newConnection()), this, SLOT(newConnection())); | ||
7 | pSrv->listen( QHostAddress::Any, 7317 ); | ||
8 | } | ||
9 | |||
10 | MainWnd::~MainWnd() | ||
11 | { | ||
12 | } | ||
13 | |||
14 | void MainWnd::newConnection() | ||
15 | { | ||
16 | while( pSrv->hasPendingConnections() ) | ||
17 | { | ||
18 | QTcpSocket *pSock = pSrv->nextPendingConnection(); | ||
19 | Gats::GatsStream *pGats = new Gats::GatsStream( *pSock ); | ||
20 | connect( pSock, SIGNAL(readyRead()), pGats, SLOT(readObject()) ); | ||
21 | connect( pGats, SIGNAL(objectRead( Gats::Object * )), | ||
22 | this, SLOT(objectRead( Gats::Object * ))); | ||
23 | } | ||
24 | } | ||
25 | |||
26 | void MainWnd::objectRead( Gats::Object *pObj ) | ||
27 | { | ||
28 | ((Gats::GatsStream *)sender())->writeObject( pObj ); | ||
29 | delete pObj; | ||
30 | } | ||