00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __JackWinNamedPipeServerChannel__
00021 #define __JackWinNamedPipeServerChannel__
00022
00023 #include "JackWinNamedPipe.h"
00024 #include "JackPlatformPlug.h"
00025 #include "JackConstants.h"
00026 #include "JackRequestDecoder.h"
00027 #include <list>
00028
00029 namespace Jack
00030 {
00031
00032 class JackServer;
00033
00034 class JackClientPipeThread : public JackRunnableInterface, public JackClientHandlerInterface
00035 {
00036
00037 private:
00038
00039 JackWinNamedPipeClient* fPipe;
00040 JackRequestDecoder* fDecoder;
00041 JackServer* fServer;
00042 JackThread fThread;
00043 int fRefNum;
00044
00045 void ClientAdd(detail::JackChannelTransactionInterface* socket, JackClientOpenRequest* req, JackClientOpenResult *res);
00046 void ClientRemove(detail::JackChannelTransactionInterface* socket, int refnum);
00047
00048 void ClientKill();
00049
00050 static HANDLE fMutex;
00051
00052 public:
00053
00054 JackClientPipeThread(JackWinNamedPipeClient* pipe);
00055 virtual ~JackClientPipeThread();
00056
00057 int Open(JackServer* server);
00058 void Close();
00059
00060
00061 bool Execute();
00062
00063
00064 bool IsRunning()
00065 {
00066 return (fRefNum >= 0);
00067 }
00068
00069 };
00070
00075 class JackWinNamedPipeServerChannel : public JackRunnableInterface
00076 {
00077
00078 private:
00079
00080 JackWinNamedPipeServer fRequestListenPipe;
00081 JackServer* fServer;
00082 JackThread fThread;
00083 char fServerName[JACK_SERVER_NAME_SIZE];
00084
00085 std::list<JackClientPipeThread*> fClientList;
00086
00087 void ClientAdd(JackWinNamedPipeClient* pipe);
00088
00089 bool ClientListen();
00090 bool ClientAccept();
00091
00092 public:
00093
00094 JackWinNamedPipeServerChannel();
00095 ~JackWinNamedPipeServerChannel();
00096
00097 int Open(const char* server_name, JackServer* server);
00098 void Close();
00099
00100 int Start();
00101 void Stop();
00102
00103
00104 bool Init();
00105 bool Execute();
00106 };
00107
00108
00109 }
00110
00111 #endif
00112