UniSet  2.0.0
LogSession.h
00001 // -------------------------------------------------------------------------
00002 #ifndef LogSession_H_
00003 #define LogSession_H_
00004 // -------------------------------------------------------------------------
00005 #include <string>
00006 #include <deque>
00007 #include <cc++/socket.h>
00008 #include "Mutex.h"
00009 #include "DebugStream.h"
00010 #include "PassiveTimer.h"
00011 // -------------------------------------------------------------------------
00013 class LogSession:
00014     public ost::TCPSession
00015 {
00016     public:
00017 
00018         LogSession( ost::TCPSocket &server, DebugStream* log, timeout_t sessTimeout=10000, timeout_t cmdTimeout=2000, timeout_t outTimeout=2000, timeout_t delay=2000 );
00019         virtual ~LogSession();
00020 
00021         typedef sigc::slot<void, LogSession*> FinalSlot;
00022         void connectFinalSession( FinalSlot sl );
00023 
00024         inline std::string getClientAddress(){ return caddr; }
00025 
00026     protected:
00027         virtual void run();
00028         virtual void final();
00029         void logOnEvent( const std::string& s );
00030         void readStream();
00031 
00032     private:
00033         typedef std::deque<std::string> LogBuffer;
00034         LogBuffer lbuf;
00035         std::string peername;
00036         std::string caddr;
00037         DebugStream* log;
00038 
00039         timeout_t sessTimeout;
00040         timeout_t cmdTimeout;
00041         timeout_t outTimeout;
00042         timeout_t delayTime;
00043         PassiveTimer ptSessionTimeout;
00044 
00045         FinalSlot slFin;
00046         std::atomic_bool cancelled;
00047         UniSetTypes::uniset_rwmutex mLBuf;
00048 
00049         DebugStream slog;
00050 };
00051 // -------------------------------------------------------------------------
00052 #endif // LogSession_H_
00053 // -------------------------------------------------------------------------