LInet::ResponseCallBack

#include " ltwrappr.h "

virtual L_INT LInet::ResponseCallBack (plConnection, uCommand, uCommandID, nError, nStatus, uParams, pParams, uExtra, pExtra)

LInet L_FAR * plConnection;

/* instance of a remote computer */

CMDTYPE uCommand;

/* command type */

L_UINT uCommandID;

/* command id */

L_INT nError;

/* status of the received data */

L_INT nStatus;

/* status */

L_UINT uParams;

/* number of parameters */

pPARAMETER pParams;

/* pointer to parameters */

L_UINT uExtra;

/* length */

L_CHAR L_FAR * pExtra;

/* pointer to extra data */

Notifies a computer that a response has been received.

Parameter

Description

plConnection

Instance of the remote computer from which the command was sent.

uCommand

The command type which prompted this response. For a list of possible values, refer to CMDTYPE.

uCommandID

Command Id. Each command sent by a member of a connection should have a unique ID. Since a member of a connection may send several commands, this ID allows that member to identify when a specific request has been completed.

nError

Determines whether the response was received properly. If not all the parameters were received properly, then nStatus will be set to an error code (most likely ERROR_TRANSFER_ABORTED). Note that this is not the status of the command. This is only an indication of whether this response has been received properly. nStatus indicates whether the command has executed properly or not.

nStatus

Status of the original command. It indicates whether the command has executed properly on the remote end. If the command completes successfully, this should be SUCCESS. Otherwise the value should be one of the Return Codes.

uParams

The number of parameters for this response.

pParams

Pointer to an array of PARAMETER structures that contain the parameters for the response.

uExtra

Length of any extra data sent with the response.

pExtra

Pointer to the extra data sent with the response.

Returns

SUCCESS

This function was successful.

< 1

An occurred. Refer to Return Codes.

Comments

A call to this overridable function is generated when a computer receives a response from a remote computer.

To process responses to commands, a class must be derived from LInet and this member function must be overridden.

Note: The parameters (uParams, pParams) and the extra data (uExtra, pExtra) for this response are not the parameters of the original command! They are only sent if this response needs to send some data to the computer that originally sent the command. An example of a response that needs to send a parameter back is the response for the CMD_CREATE_WIN command. In this case, the response will need to send back the window handle of the newly created window. Most of the responses will only send back the status of the command (nStatus).

The string parameters and pExtra are only valid during this call. Do not free these pointers and don’t try to keep references to the strings. If the data is needed outside this function, allocate buffers and copy the data into them.

Required DLLs and Libraries

LTNET

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application.

See Also

Functions:

LInet::CommandCallBack, LInet::SendRsp, LInet::SendLoadRsp, LInet::SendCreateWinRsp, LInet::SendAttachBitmapRsp, LInet::SendSaveRsp, LInet::SendSizeWinRsp, LInet::SendShowWinRsp, LInet::SendCloseWinRsp, LInet::SendFreeBitmapRsp, LInet::SendSetRectRsp

Topics:

Sending Commands and Responses

 

A Client Server Diagram: Sending Commands and Responses

Example

L_INT CMyNet::ResponseCallBack(
                               LInet L_FAR * plConnection,
                               CMDTYPE     uCommand,
                               L_UINT      uCommandID,
                               L_INT       nError,
                               L_INT       nStatus,
                               L_UINT      uParams, 
                               pPARAMETER  pParams, 
                               L_UINT      uExtra,
                               L_CHAR L_FAR*pExtra
                               )
{
   CString strMsg;

   L_TCHAR *pszString=TEXT("INVALID CMD");
   
   switch (uCommand)
   {
   case CMD_LOAD:
      pszString = TEXT("CMD_LOAD");
      break;
      
   case CMD_SAVE:
      pszString = TEXT("CMD_SAVE");
      break;
      
   case CMD_CREATE_WIN:
      pszString = TEXT("CMD_CREATE_WIN");
      break;
      
   case CMD_SIZE_WIN:
      pszString = TEXT("CMD_SIZE_WIN");
      break;
      
   case CMD_CLOSE_WIN:
      pszString = TEXT("CMD_CLOSE_WIN");
      break;
      
   case CMD_SHOW_WIN:
      pszString = TEXT("CMD_SHOW_WIN");
      break;
      
   case CMD_SET_RECT:
      pszString = TEXT("CMD_SET_RECT");
      break;
      
   case CMD_SEND_ANN:
      pszString = TEXT("CMD_SEND_ANN");
      break;
      
   case CMD_ATTACH_BITMAP:
      pszString = TEXT("CMD_ATTACH_BITMAP");
      break;
      
   case CMD_FREE_BITMAP:
      pszString = TEXT("CMD_FREE_BITMAP");
      break;
      
   case CMD_FLIP:
      pszString = TEXT("CMD_FLIP");
      break;
      
   case CMD_GET:
      pszString = TEXT("CMD_GET");
      break;
   }
   
   strMsg.Format(TEXT("Response to %s, id=%d, nError=%d, uParams=%d, nStatus=%d%s received"), 
      pszString, 
      uCommandID, 
      nError, 
      uParams, 
      nStatus, uExtra ? TEXT(", uExtra") : TEXT("")
      );
   MessageBox(NULL, strMsg, TEXT(""), MB_OK);
   
   return SUCCESS;
}