From f4c20290509d7ed3a8fd5304577e7a4cc0b9d974 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Tue, 3 Apr 2007 03:49:53 +0000 Subject: Ok, no code is left in src, it's all in src/old. We'll gradually move code back into src as it's fixed and re-org'd. This includes tests, which, I may write a unit test system into libbu++ just to make my life easier. --- src/old/tests/srvstress.cpp | 91 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 src/old/tests/srvstress.cpp (limited to 'src/old/tests/srvstress.cpp') diff --git a/src/old/tests/srvstress.cpp b/src/old/tests/srvstress.cpp new file mode 100644 index 0000000..d9a9a1c --- /dev/null +++ b/src/old/tests/srvstress.cpp @@ -0,0 +1,91 @@ +#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() + { + return true; + } + + 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