Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

PClient Class Reference

A pipe client class. More...

#include <PClient.h>

Inherits Pipe.

Inherited by MouseClient, and ScreenClient.

List of all members.

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 ()


Detailed Description

Handles the connecting to a PServer based pipe. This class is intended for use in VCC. Functions should be non-blocking.

Definition at line 23 of file PClient.h.


Constructor & Destructor Documentation

PClient::PClient const TString   name,
const bool    isOut
 

Constructor

Parameters:
name  : A TString from which the pipe name is derived
isOut  : Boolean, true if this is an outgoing pipe

Definition at line 20 of file PClient.cpp.

References Pipe::hPipe.

00021 : Pipe( name, isOut )
00022 {
00023     hPipe = INVALID_HANDLE_VALUE;
00024 }

PClient::~PClient   [virtual]
 

Object Destructor

Definition at line 29 of file PClient.cpp.

References disconnect().

00030 {
00031     disconnect();
00032 }


Member Function Documentation

DWORD PClient::connect   [virtual]
 

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 }

void PClient::disconnect   [virtual]
 

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 }

bool PClient::isConnected  
 

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 }


The documentation for this class was generated from the following files:
Generated on Mon Mar 25 06:30:00 2002 for Window Dressing by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001