I'm trying to get shared client data areas working and not having a lot of luck.
I can set up the area in one simconnect client, and although another can request it and the callback seems to return the requested definition, it's always empty. (i.e. The dwData pointer is always zero.)
Here's a couple of samples I put together to testClient Data away from my main application. (and these don't work either.)
The data setting client application:
The data retrieval client application:
Anybody got any ideas as to what I'm doing wrong? The above example just tries to set a float64 in the shared area and get it back from another client. The definition ids and request ids are different because they should be client dependent, where as the client data id (1) and client name has to be identical in both. (This is how I understand it.
I'm confused. Everything normally works so easily...
Si
EDIT: Note: To check the received data I'm just breaking on the "switch(pObjData->dwRequestID)" line and inspecting the structure.
I can set up the area in one simconnect client, and although another can request it and the callback seems to return the requested definition, it's always empty. (i.e. The dwData pointer is always zero.)
Here's a couple of samples I put together to testClient Data away from my main application. (and these don't work either.)
The data setting client application:
Code:
#include <windows.h>
#include <tchar.h>
#include <stdio.h>
#include <strsafe.h>
#include "SimConnect.h"
typedef double FLOAT64;
HANDLE hSimConnect = NULL;
static enum DATA_DEFINE_ID {
DEFINITION_1 = 1,
};
static enum DATA_REQUEST_ID {
REQUEST_1 = 1,
};
void CALLBACK MyDispatchProcTCDS(SIMCONNECT_RECV* pData, DWORD cbData, void *pContext)
{
switch(pData->dwID)
{
case SIMCONNECT_RECV_ID_CLIENT_DATA:
{
SIMCONNECT_RECV_CLIENT_DATA *pObjData = (SIMCONNECT_RECV_CLIENT_DATA*)pData;
switch(pObjData->dwRequestID)
{
case REQUEST_1:
{
break;
}
}
break;
}
}
}
FLOAT64 testData = 321;
void testClientDataSet()
{
HRESULT hr;
if (SUCCEEDED(SimConnect_Open(&hSimConnect, "Test Client Data - Set", NULL, 0, 0, 0)))
{
printf("\nConnected to ESP!");
hr = SimConnect_MapClientDataNameToID(hSimConnect,"TestClientData",1);
hr = SimConnect_AddToClientDataDefinition(hSimConnect,DEFINITION_1,SIMCONNECT_CLIENTDATAOFFSET_AUTO,SIMCONNECT_CLIENTDATATYPE_FLOAT64,0,0);
hr = SimConnect_CreateClientData(hSimConnect,
1,
8,
SIMCONNECT_CREATE_CLIENT_DATA_FLAG_READ_ONLY );
hr = SimConnect_SetClientData(hSimConnect,
1,
DEFINITION_1,
0,0,
sizeof(FLOAT64),
&testData);
while( 1 )
{
hr = SimConnect_CallDispatch(hSimConnect, MyDispatchProcTCDS, NULL);
Sleep(1);
}
hr = SimConnect_Close(hSimConnect);
}
}
int __cdecl _tmain(int argc, _TCHAR* argv[])
{
testClientDataSet();
return 0;
}
The data retrieval client application:
Code:
#include <windows.h>
#include <tchar.h>
#include <stdio.h>
#include <strsafe.h>
#include "SimConnect.h"
typedef double FLOAT64;
HANDLE hSimConnect = NULL;
static enum DATA_DEFINE_ID {
DEFINITION_1=222,
};
static enum DATA_REQUEST_ID {
REQUEST_1 = 123,
};
void CALLBACK MyDispatchProcTCDR(SIMCONNECT_RECV* pData, DWORD cbData, void *pContext)
{
switch(pData->dwID)
{
case SIMCONNECT_RECV_ID_CLIENT_DATA:
{
SIMCONNECT_RECV_CLIENT_DATA *pObjData = (SIMCONNECT_RECV_CLIENT_DATA*)pData;
switch(pObjData->dwRequestID)
{
case REQUEST_1:
{
break;
}
}
break;
}
}
}
void testClientDataRequest()
{
HRESULT hr;
if (SUCCEEDED(SimConnect_Open(&hSimConnect, "Test Client Data - Get", NULL, 0, 0, 0)))
{
printf("\nConnected to ESP!");
hr = SimConnect_MapClientDataNameToID(hSimConnect,"TestClientData",1);
hr = SimConnect_AddToClientDataDefinition(hSimConnect,DEFINITION_1,SIMCONNECT_CLIENTDATAOFFSET_AUTO,SIMCONNECT_CLIENTDATATYPE_FLOAT64,0,0);
while( 1 )
{
hr = SimConnect_RequestClientData(hSimConnect, 1, REQUEST_1, DEFINITION_1, SIMCONNECT_CLIENT_DATA_PERIOD_SECOND, 0, 0, 0);
hr = SimConnect_CallDispatch(hSimConnect, MyDispatchProcTCDR, NULL);
Sleep(1);
}
hr = SimConnect_Close(hSimConnect);
}
}
int __cdecl _tmain(int argc, _TCHAR* argv[])
{
testClientDataRequest();
return 0;
}
Anybody got any ideas as to what I'm doing wrong? The above example just tries to set a float64 in the shared area and get it back from another client. The definition ids and request ids are different because they should be client dependent, where as the client data id (1) and client name has to be identical in both. (This is how I understand it.
I'm confused. Everything normally works so easily...
Si
EDIT: Note: To check the received data I'm just breaking on the "switch(pObjData->dwRequestID)" line and inspecting the structure.

