Jack2 1.9.6
|
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 00021 #ifndef __JackWinNamedPipeServerChannel__ 00022 #define __JackWinNamedPipeServerChannel__ 00023 00024 #include "JackWinNamedPipe.h" 00025 #include "JackPlatformPlug.h" 00026 #include <list> 00027 00028 namespace Jack 00029 { 00030 00031 class JackServer; 00032 00033 class JackClientPipeThread : public JackRunnableInterface 00034 { 00035 00036 private: 00037 00038 JackWinNamedPipeClient* fPipe; 00039 JackServer* fServer; 00040 JackThread fThread; 00041 int fRefNum; 00042 00043 void ClientAdd(char* name, int pid, int* shared_engine, int* shared_client, int* shared_graph, int* result); 00044 void ClientRemove(); 00045 void ClientKill(); 00046 00047 static HANDLE fMutex; 00048 00049 public: 00050 00051 JackClientPipeThread(JackWinNamedPipeClient* pipe); 00052 virtual ~JackClientPipeThread(); 00053 00054 int Open(JackServer* server); // Open the Server/Client connection 00055 void Close(); // Close the Server/Client connection 00056 00057 bool HandleRequest(); 00058 00059 // JackRunnableInterface interface 00060 bool Execute(); 00061 00062 // To be used for find out if the object can be deleted 00063 bool IsRunning() 00064 { 00065 return (fRefNum >= 0); 00066 } 00067 }; 00068 00073 class JackWinNamedPipeServerChannel : public JackRunnableInterface 00074 { 00075 00076 private: 00077 00078 JackWinNamedPipeServer fRequestListenPipe; // Pipe to create request socket for the client 00079 JackServer* fServer; 00080 JackThread fThread; // Thread to execute the event loop 00081 char fServerName[64]; 00082 00083 std::list<JackClientPipeThread*> fClientList; 00084 00085 void ClientAdd(JackWinNamedPipeClient* pipe); 00086 00087 public: 00088 00089 JackWinNamedPipeServerChannel(); 00090 ~JackWinNamedPipeServerChannel(); 00091 00092 int Open(const char* server_name, JackServer* server); // Open the Server/Client connection 00093 void Close(); // Close the Server/Client connection 00094 00095 int Start(); 00096 00097 // JackRunnableInterface interface 00098 bool Init(); 00099 bool Execute(); 00100 }; 00101 00102 00103 } // end of namespace 00104 00105 #endif 00106