Page 1 of 1

Can i encapsulate this function __cdecl DataHandler?

Posted: Wed Nov 24, 2010 5:51 pm
by prap19
In the Sample code provided in the SDK, the function __cdecl DataHandler is responsible for receiving data from server? Am I right?
My application is fully object oriented so I will need to encapsulate this function.
Eg: void myClass::__cdecl DataHandler(sFrameOfMocapData* data, void* pUserData)

How can I do it? Or is there any other way that i can obtain data from the server.
Looking forward for your answers.

Re: Can i encapsulate this function __cdecl DataHandler?

Posted: Mon Nov 29, 2010 12:24 pm
by morgan
Yes you can do this by declaring the member function static:

static void DataHandler(sFrameOfMocapData* data, void* pUserData);

If you need access to the class instance during the callback, you can pass an instance of the class to SetDataCallback. Something like:

theClient->SetDataCallback( pMyObject->DataHandler, pMyObject );

hope this helps,