Jack2  1.9.8
JackWinNamedPipeServerChannel.h
1 /*
2  Copyright (C) 2004-2008 Grame
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU Lesser General Public License as published by
6  the Free Software Foundation; either version 2.1 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU Lesser General Public License for more details.
13 
14  You should have received a copy of the GNU Lesser General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 
18  */
19 
20 
21 #ifndef __JackWinNamedPipeServerChannel__
22 #define __JackWinNamedPipeServerChannel__
23 
24 #include "JackWinNamedPipe.h"
25 #include "JackPlatformPlug.h"
26 #include "JackConstants.h"
27 #include <list>
28 
29 namespace Jack
30 {
31 
32 class JackServer;
33 
35 {
36 
37  private:
38 
40  JackServer* fServer;
41  JackThread fThread;
42  int fRefNum;
43 
44  void ClientAdd(char* name, int pid, int uuid, int* shared_engine, int* shared_client, int* shared_graph, int* result);
45  void ClientRemove();
46  void ClientKill();
47 
48  static HANDLE fMutex;
49 
50  public:
51 
53  virtual ~JackClientPipeThread();
54 
55  int Open(JackServer* server); // Open the Server/Client connection
56  void Close(); // Close the Server/Client connection
57 
58  bool HandleRequest();
59 
60  // JackRunnableInterface interface
61  bool Execute();
62 
63  // To be used for find out if the object can be deleted
64  bool IsRunning()
65  {
66  return (fRefNum >= 0);
67  }
68 };
69 
75 {
76 
77  private:
78 
79  JackWinNamedPipeServer fRequestListenPipe; // Pipe to create request socket for the client
80  JackServer* fServer;
81  JackThread fThread; // Thread to execute the event loop
82  char fServerName[JACK_SERVER_CONTROL_NAME_SIZE];
83 
84  std::list<JackClientPipeThread*> fClientList;
85 
86  void ClientAdd(JackWinNamedPipeClient* pipe);
87 
88  public:
89 
92 
93  int Open(const char* server_name, JackServer* server); // Open the Server/Client connection
94  void Close(); // Close the Server/Client connection
95 
96  int Start();
97  void Stop();
98 
99  // JackRunnableInterface interface
100  bool Init();
101  bool Execute();
102 };
103 
104 
105 } // end of namespace
106 
107 #endif
108