diff options
author | Mike Buland <eichlan@xagasoft.com> | 2006-10-11 15:47:45 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2006-10-11 15:47:45 +0000 |
commit | 745875139b5ee46e469927d410364bfeeedb2995 (patch) | |
tree | 393d6ded249fdca428539098caeb285479fa7ab3 /src/tests/srvstress | |
parent | df6f199b4e158d1d6cfb99d45258efa22afee715 (diff) | |
download | libbu++-745875139b5ee46e469927d410364bfeeedb2995.tar.gz libbu++-745875139b5ee46e469927d410364bfeeedb2995.tar.bz2 libbu++-745875139b5ee46e469927d410364bfeeedb2995.tar.xz libbu++-745875139b5ee46e469927d410364bfeeedb2995.zip |
Despite some svn oddness, I'm now moving to a new setup for the tests, that's
very much like the original one, but now using build. You will need the latest
build in order to build the tests.
Diffstat (limited to 'src/tests/srvstress')
-rw-r--r-- | src/tests/srvstress/main.cpp | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/src/tests/srvstress/main.cpp b/src/tests/srvstress/main.cpp new file mode 100644 index 0000000..7fe7657 --- /dev/null +++ b/src/tests/srvstress/main.cpp | |||
@@ -0,0 +1,90 @@ | |||
1 | #include "connectionmanager.h" | ||
2 | #include "programlink.h" | ||
3 | #include "linkedlist.h" | ||
4 | #include "protocol.h" | ||
5 | |||
6 | class StressProtocol : public Protocol | ||
7 | { | ||
8 | public: | ||
9 | bool onNewData() | ||
10 | { | ||
11 | switch( getConnection()->getInput()[0] ) | ||
12 | { | ||
13 | case 'd': | ||
14 | throw "Hello"; | ||
15 | break; | ||
16 | |||
17 | case 'w': | ||
18 | getConnection()->appendOutput("Hello"); | ||
19 | break; | ||
20 | }; | ||
21 | |||
22 | return true; | ||
23 | } | ||
24 | |||
25 | bool onNewConnection() | ||
26 | { | ||
27 | return true; | ||
28 | } | ||
29 | }; | ||
30 | |||
31 | class StressMonitor : public ConnectionMonitor, public ProgramLink | ||
32 | { | ||
33 | public: | ||
34 | bool init() | ||
35 | { | ||
36 | return true; | ||
37 | } | ||
38 | |||
39 | bool deInit() | ||
40 | { | ||
41 | return true; | ||
42 | } | ||
43 | |||
44 | bool timeSlice() | ||
45 | { | ||
46 | } | ||
47 | |||
48 | bool onNewConnection( Connection *pCon, int nPort ) | ||
49 | { | ||
50 | StressProtocol *sp = new StressProtocol(); | ||
51 | pCon->setProtocol( sp ); | ||
52 | |||
53 | printf(" sys: New connection: socket(%d), port(%d)\n", | ||
54 | pCon->getSocket(), nPort ); | ||
55 | |||
56 | return true; | ||
57 | } | ||
58 | |||
59 | bool onClosedConnection( Connection *pCon ) | ||
60 | { | ||
61 | printf(" sys: Closed connection: socket(%d)\n", | ||
62 | pCon->getSocket() ); | ||
63 | |||
64 | return true; | ||
65 | } | ||
66 | |||
67 | LinkMessage *processIRM( LinkMessage *pMsg ) | ||
68 | { | ||
69 | return NULL; | ||
70 | } | ||
71 | }; | ||
72 | |||
73 | int main() | ||
74 | { | ||
75 | printf("Starting server...\n"); | ||
76 | |||
77 | ConnectionManager srv; | ||
78 | StressMonitor telnet; | ||
79 | |||
80 | srv.setConnectionMonitor( &telnet ); | ||
81 | |||
82 | srv.startServer( 4001 ); | ||
83 | |||
84 | for(;;) | ||
85 | { | ||
86 | srv.scanConnections( 5000, false ); | ||
87 | } | ||
88 | |||
89 | return 0; | ||
90 | } | ||