Jack2
1.9.10
|
00001 /* 00002 Copyright (C) 2004-2008 Grame 00003 00004 This program is free software; you can redistribute it and/or modify 00005 it under the terms of the GNU Lesser General Public License as published by 00006 the Free Software Foundation; either version 2.1 of the License, or 00007 (at your option) any later version. 00008 00009 This program is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 GNU Lesser General Public License for more details. 00013 00014 You should have received a copy of the GNU Lesser General Public License 00015 along with this program; if not, write to the Free Software 00016 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 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); // Open the Server/Client connection 00058 void Close(); // Close the Server/Client connection 00059 00060 // JackRunnableInterface interface 00061 bool Execute(); 00062 00063 // To be used for find out if the object can be deleted 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; // Pipe to create request socket for the client 00081 JackServer* fServer; 00082 JackThread fThread; // Thread to execute the event loop 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); // Open the Server/Client connection 00098 void Close(); // Close the Server/Client connection 00099 00100 int Start(); 00101 void Stop(); 00102 00103 // JackRunnableInterface interface 00104 bool Init(); 00105 bool Execute(); 00106 }; 00107 00108 00109 } // end of namespace 00110 00111 #endif 00112