Vault
4.1
|
00001 /* 00002 Copyright c1997-2014 Trygve Isaacson. All rights reserved. 00003 This file is part of the Code Vault version 4.1 00004 http://www.bombaydigital.com/ 00005 License: MIT. See LICENSE.md in the Vault top level directory. 00006 */ 00007 00008 #ifndef vmessageinputthread_h 00009 #define vmessageinputthread_h 00010 00013 #include "vsocketthread.h" 00014 #include "vsocketstream.h" 00015 #include "vserver.h" 00016 #include "vbinaryiostream.h" 00017 #include "vmessage.h" 00018 00019 class VMessageHandler; 00020 00031 class VMessageInputThread : public VSocketThread { 00032 public: 00033 00046 VMessageInputThread(const VString& threadBaseName, VSocket* socket, VListenerThread* ownerThread, VServer* server, const VMessageFactory* messageFactory); 00050 virtual ~VMessageInputThread(); 00051 00057 virtual void run(); 00058 00064 void attachSession(VClientSessionPtr session); 00065 00072 void setHasOutputThread(bool hasOutputThread) { mHasOutputThread = hasOutputThread; } 00073 00074 protected: 00075 00080 virtual void _processNextRequest(); 00086 virtual void _dispatchMessage(VMessagePtr message); 00094 virtual void _handleNoMessageHandler(VMessagePtr /*message*/) {} 00100 virtual void _beforeProcessMessage(VMessageHandler* /*handler*/, VMessagePtr /*message*/) {} 00107 virtual void _callProcessMessage(VMessageHandler* handler); 00113 virtual void _afterProcessMessage(VMessageHandler* /*handler*/) {} 00114 00115 VSocketStream mSocketStream; 00116 VBinaryIOStream mInputStream; 00117 bool mConnected; 00118 VClientSessionPtr mSession; 00119 VServer* mServer; 00120 const VMessageFactory* mMessageFactory; 00121 volatile bool mHasOutputThread; 00122 00123 private: 00124 00125 VMessageInputThread(const VMessageInputThread&); // not copyable 00126 VMessageInputThread& operator=(const VMessageInputThread&); // not assignable 00127 }; 00128 00134 class VBentoMessageInputThread : public VMessageInputThread { 00135 public: 00136 00137 VBentoMessageInputThread(const VString& threadBaseName, VSocket* socket, VListenerThread* ownerThread, VServer* server, const VMessageFactory* messageFactory); 00138 ~VBentoMessageInputThread() {} 00139 00140 protected: 00141 00142 virtual void _handleNoMessageHandler(VMessagePtr message); 00143 virtual void _callProcessMessage(VMessageHandler* handler); 00144 00145 }; 00146 00147 #endif /* vmessageinputthread_h */