aboutsummaryrefslogtreecommitdiff
path: root/src/tests/multiserver.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2011-03-30 22:33:41 +0000
committerMike Buland <eichlan@xagasoft.com>2011-03-30 22:33:41 +0000
commit4b9289cfb260f4bcecaf23a810584ef6ef8e8501 (patch)
tree79136af08c7e42ba3322f0d73e9779e4354b318a /src/tests/multiserver.cpp
parentc7636dc954eddfe58f7959392602fbc9072d77e7 (diff)
downloadlibbu++-4b9289cfb260f4bcecaf23a810584ef6ef8e8501.tar.gz
libbu++-4b9289cfb260f4bcecaf23a810584ef6ef8e8501.tar.bz2
libbu++-4b9289cfb260f4bcecaf23a810584ef6ef8e8501.tar.xz
libbu++-4b9289cfb260f4bcecaf23a810584ef6ef8e8501.zip
Ok, string stuff is working much, much better, a load of new unit tests have
been added, and I deleted a whole slew of stupid old tests that I don't need.
Diffstat (limited to '')
-rw-r--r--src/tests/multiserver.cpp76
1 files changed, 0 insertions, 76 deletions
diff --git a/src/tests/multiserver.cpp b/src/tests/multiserver.cpp
deleted file mode 100644
index 12f4681..0000000
--- a/src/tests/multiserver.cpp
+++ /dev/null
@@ -1,76 +0,0 @@
1/*
2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#include "bu/multiserver.h"
9#include "bu/protocol.h"
10#include "bu/client.h"
11
12class ProtocolRaw : public Bu::Protocol
13{
14public:
15 virtual void onNewConnection( Bu::Client *pClient )
16 {
17 pClient->write("Raw echo\n");
18 }
19
20 virtual void onNewData( Bu::Client *pClient )
21 {
22 char buf[1024];
23 while( pClient->hasInput() )
24 {
25 int iAmnt = pClient->read( buf, 1024 );
26 pClient->write( buf, iAmnt );
27 }
28 }
29};
30
31class ProtocolRot13 : public Bu::Protocol
32{
33public:
34 virtual void onNewConnection( Bu::Client *pClient )
35 {
36 pClient->write("Rot13 echo\n");
37 }
38
39 virtual void onNewData( Bu::Client *pClient )
40 {
41 while( pClient->hasInput() )
42 {
43 char sTmp[1024];
44 int iAmnt = pClient->read( sTmp, 1024 );
45 for( int j = 0; j < iAmnt; j++ )
46 {
47 if( sTmp[j] >= 'a' && sTmp[j] <= 'z' )
48 {
49 sTmp[j] = ((sTmp[j]-'a'+13)%26) + 'a';
50 }
51 else if( sTmp[j] >= 'A' && sTmp[j] <= 'Z' )
52 {
53 sTmp[j] = ((sTmp[j]-'A'+13)%26) + 'A';
54 }
55 }
56 pClient->write( sTmp, iAmnt );
57 }
58 }
59};
60
61int main()
62{
63 Bu::MultiServer msMain;
64
65 msMain.addProtocol( Bu::genProtocol<ProtocolRaw>, 5550 );
66 msMain.addProtocol( Bu::genProtocol<ProtocolRot13>, 5551 );
67 msMain.setTimeout( 5, 0 );
68
69 for(;;)
70 {
71 msMain.scan();
72 }
73
74 return 0;
75}
76