From a77e41eee42b99282c05d268479ba5ebb11dc095 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Wed, 11 Oct 2006 15:54:09 +0000 Subject: Rearranged the tests, now it's like the old style, which I like more for some reason. --- src/tests/srvstress.cpp | 90 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 src/tests/srvstress.cpp (limited to 'src/tests/srvstress.cpp') diff --git a/src/tests/srvstress.cpp b/src/tests/srvstress.cpp new file mode 100644 index 0000000..7fe7657 --- /dev/null +++ b/src/tests/srvstress.cpp @@ -0,0 +1,90 @@ +#include "connectionmanager.h" +#include "programlink.h" +#include "linkedlist.h" +#include "protocol.h" + +class StressProtocol : public Protocol +{ +public: + bool onNewData() + { + switch( getConnection()->getInput()[0] ) + { + case 'd': + throw "Hello"; + break; + + case 'w': + getConnection()->appendOutput("Hello"); + break; + }; + + return true; + } + + bool onNewConnection() + { + return true; + } +}; + +class StressMonitor : public ConnectionMonitor, public ProgramLink +{ +public: + bool init() + { + return true; + } + + bool deInit() + { + return true; + } + + bool timeSlice() + { + } + + bool onNewConnection( Connection *pCon, int nPort ) + { + StressProtocol *sp = new StressProtocol(); + pCon->setProtocol( sp ); + + printf(" sys: New connection: socket(%d), port(%d)\n", + pCon->getSocket(), nPort ); + + return true; + } + + bool onClosedConnection( Connection *pCon ) + { + printf(" sys: Closed connection: socket(%d)\n", + pCon->getSocket() ); + + return true; + } + + LinkMessage *processIRM( LinkMessage *pMsg ) + { + return NULL; + } +}; + +int main() +{ + printf("Starting server...\n"); + + ConnectionManager srv; + StressMonitor telnet; + + srv.setConnectionMonitor( &telnet ); + + srv.startServer( 4001 ); + + for(;;) + { + srv.scanConnections( 5000, false ); + } + + return 0; +} -- cgit v1.2.3