DispatchProc
The DispatchProc function is written by the developer of the SimConnect client, as a callback function to handle all the communications with the server.
Syntax
void CALLBACK DispatchProc(
SIMCONNECT_RECV* pData,
DWORD cbData,
void * pContext
);
Parameters
Parameter | Description | Type |
---|---|---|
pData | Pointer to a data buffer, to be treated initially as a SIMCONNECT_RECV structure. If you are going to make a copy of the data buffer (which is maintained by the SimConnect client library) make sure that the defined buffer is large enough (the size of the returned data structure is one member of the SIMCONNECT_RECV structure. | Integer |
cbData | The size of the data buffer, in bytes. | Integer |
pContext | Contains the pointer specified by the client in the SimConnect_CallDispatch function call. | Integer |
Return Values
This function does not return a value.
Example
void CALLBACK MyDispatchProc(SIMCONNECT_RECV* pData, DWORD cbData)
{
case SIMCONNECT_RECV_ID_OPEN:
SIMCONNECT_RECV_OPEN *openData = (SIMCONNECT_RECV_OPEN*) pData;
break;
case SIMCONNECT_RECV_ID_EVENT:
SIMCONNECT_RECV_EVENT *evt = (SIMCONNECT_RECV_EVENT*) pData;
break;
case SIMCONNECT_RECV_ID_EVENT_FILENAME:
SIMCONNECT_RECV_EVENT_FILENAME *evt = (SIMCONNECT_RECV_EVENT_FILENAME)*) pData;
break;
case SIMCONNECT_RECV_ID_EVENT_OBJECT_ADDREMOVE:
SIMCONNECT_RECV_EVENT_OBJECT_ADDREMOVE *evt = (SIMCONNECT_RECV_EVENT_OBJECT_ADDREMOVE*) pData;
break;
case SIMCONNECT_RECV_ID_EVENT_FRAME:
SIMCONNECT_RECV_EVENT_FRAME *evt = (SIMCONNECT_RECV_EVENT_FRAME*) pData;
break;
case SIMCONNECT_RECV_ID_SIMOBJECT_DATA:
SIMCONNECT_RECV_SIMOBJECT_DATA *pObjData = (SIMCONNECT_RECV_SIMOBJECT_DATA*) pData;
break;
case SIMCONNECT_RECV_ID_SIMOBJECT_DATA_BYTYPE:
SIMCONNECT_RECV_SIMOBJECT_DATA_BYTYPE *pObjData = (SIMCONNECT_RECV_SIMOBJECT_DATA_BYTYPE*) pData;
break;
case SIMCONNECT_RECV_ID_QUIT:
case SIMCONNECT_RECV_ID_EXCEPTION:
SIMCONNECT_RECV_EXCEPTION *except = (SIMCONNECT_RECV_EXCEPTION*) pData;
break;
case SIMCONNECT_RECV_ID_WEATHER_OBSERVATION:
SIMCONNECT_RECV_WEATHER_OBSERVATION* pWxData = (SIMCONNECT_RECV_WEATHER_OBSERVATION*) pData;
const char* pszMETAR = (const char*) (pWxData+1);
break;
default:
break;
}
Remarks
This function can be named appropriately by the client developer. The name of the function is passed to the client-side library with the SimConnect_CallDispatch function call. Handle all the callback events in this function. If you do not wish to implement a callback function use SimConnect_GetNextDispatch.
To receive time based notifications, see the SimConnect_SubscribeToSystemEvent function. To receive event based notifications see the SimConnect_AddClientEventToNotificationGroup function. To send an event to be received by other clients, see the SimConnect_TransmitClientEvent function.
See Also