#include <PClient.h>
Inherits Pipe.
Inherited by MouseClient, and ScreenClient.
Public Methods | |
| bool | isConnected () |
| Returns true if the server is connected to a client. More... | |
| virtual DWORD | connect () |
| virtual void | disconnect () |
| PClient (const TString &, const bool) | |
| virtual | ~PClient () |
Definition at line 23 of file PClient.h.
|
||||||||||||
|
Constructor
Definition at line 20 of file PClient.cpp. References Pipe::hPipe.
|
|
|
Object Destructor Definition at line 29 of file PClient.cpp. References disconnect().
00030 {
00031 disconnect();
00032 }
|
|
|
Attempts to connect to server, fails if server isn't serving. Reimplemented in MouseClient. Definition at line 54 of file PClient.cpp. References Pipe::clientStayConnected, Pipe::hPipe, isConnected(), Pipe::isOutbound, PC_ALREADY_CONNECTED, PC_BUSY, PC_CONNECTED, PC_FAILED, PC_NOT_RESET, and Pipe::pipeName. Referenced by MouseClient::connect(), and WinMain().
00055 {
00056 if( isConnected() )
00057 return PC_ALREADY_CONNECTED;
00058
00059 if( WaitForSingleObject(clientStayConnected, 0) == WAIT_OBJECT_0 ){
00060 return PC_NOT_RESET; // Server yet to process disconnect event
00061 }
00062
00063 hPipe = CreateFile(
00064 pipeName, // pipe name
00065 isOutbound ? GENERIC_WRITE : GENERIC_READ, // read and write access
00066 0, // no sharing
00067 NULL, // no security attributes
00068 OPEN_EXISTING, // opens existing pipe
00069 0, // default attributes
00070 NULL); // no template file
00071
00072 if (hPipe == INVALID_HANDLE_VALUE){
00073 if (GetLastError() == ERROR_PIPE_BUSY)
00074 return PC_BUSY;
00075 else
00076 return PC_FAILED;
00077 } else
00078 return PC_CONNECTED;
00079 }
|
|
|
Disconnects the pipe and resets the servers event (signaling it to disconnect). Reimplemented from Pipe. Reimplemented in MouseClient. Definition at line 42 of file PClient.cpp. References Pipe::hPipe, and Pipe::serverStayConnected. Referenced by MouseClient::connect(), MouseClient::disconnect(), isConnected(), WinMain(), and ~PClient().
00043 {
00044 if(hPipe != INVALID_HANDLE_VALUE){
00045 CloseHandle(hPipe);
00046 hPipe = INVALID_HANDLE_VALUE;
00047 }
00048 ResetEvent(serverStayConnected);
00049 }
|
|
|
The makes sure the client is not wanting to disconnect, disconnecting as necessary. This should be called each time before a pipe operation is conducted. Definition at line 88 of file PClient.cpp. References disconnect(), Pipe::hPipe, and Pipe::serverStayConnected. Referenced by connect(), and MouseClient::deQueueMessage().
00089 {
00090 if( WaitForSingleObject(serverStayConnected, 0) == WAIT_OBJECT_0 ){
00091 this->disconnect();
00092 }
00093
00094 return hPipe != INVALID_HANDLE_VALUE;
00095 }
|
1.2.13.1 written by Dimitri van Heesch,
© 1997-2001