LJHCClient
API
By Andrew Strauss
This client was designed to be VERY simple and
clean. Server settings are read from an ini file
These settings include he server port. Here is an example of an ini
file:
[Server]
port=2507
------------------------------------------------------------------------------------
/**
*
* LJHCClient::Cleanup
*
* Description:
*
Disconnects from the server and cleans up DirectX
*
* Parameters:
*
-None
*
* Return values:
* -None
*
**/
void LJHCClient::Cleanup()
/**
*
* LJHCClient::Disconnect
*
* Description:
*
Disconnects from the server and cleans up DirectX
*
Then reinits direct play....all that is needed
to
*
connect to a server after a call to disconnect is
* a call to connect
*
* Parameters:
*
-None
*
* Return values:
* -None
*
**/
void LJHCClient::Disconnect()
/**
*
* LJHCClient::Connect
*
* Description:
*
Connects to a LJHCServer
*
* Parameters:
*
-TCHAR* theIP
* the IP address of the server
*
* Return values:
* -E_FAIL if we couldn't connect
*
-S_OK if we could connect
*
-Some other bad thing returned by a DirectX funciton
* FAILED(hr) will return true on this bad thing
*
**/
HRESULT LJHCClient::Connect(TCHAR* theIP)
/**
*
* LJHCClient::Init
*
* Description:
* Initilizes
DirectPlay and COM. Reads in
settings
* from ini file
*
* Parameters:
*
-LPCTSTR initFile
* ini file that specifies port
*
-PFNDPNMESSAGEHANDLER blah
*
Direct play message handler for the client
*
Sample prototype:
*
HRESULT WINAPI DirectPlayMessageHandler(PVOID pvUserContext,
*
DWORD dwMessageId, PVOID pMsgBuffer);
*
* Return values:
* -true if initilization
was succesful
*
-false if we are already connected or
* direct play failed
to initalize
*
**/
bool LJHCClient::Init(LPCTSTR initFile, PFNDPNMESSAGEHANDLER blah)
/**
*
* LJHCClient::Send
*
* Description:
*
Sends a gamemsg to the server
* that the client is connected to.
*
* Parameters:
*
-GAMEMSG_GENERIC *msg
*
The game message we wanted to send to the server
* -int size
*
The size of the message
*
* Return values:
* -E_FAIL - not connected to the server
* -DPNERR_TIMEDOUT - the operation couldn't
* be
completed b/c it timed out
* -DPNERR_INVALIDFLAGS - the flags passed to send()
* were invalid (shouldn't happen)
* -DPNSUCCESS_PENDING - if send()
was processed
* asynchronously
* -S_OK - method was synchronous and succesful
*
**/
HRESULT LJHCClient::Send(GAMEMSG_GENERIC *msg, int
size)