I'm trying to fire a Social Asynchronous event from a DLL on Windows. There is a tutorial for this here at the bottom.
What I don't understand is the following
When your extension is loaded this callback should fire immediately and be passed in pointers to the four functions.
I guess I should call the function (RegisterCallbacks) from GML since the callback is defined as dllexport.
Here's the callback function
__declspec (dllexport) void RegisterCallbacks(char *arg1, char *arg2, char *arg3, char *arg4 )
{
void (*CreateAsynEventWithDSMapPtr)(int,int) = (void (*)(int,int))(arg1);
int(*CreateDsMapPtr)(int _num,...) = (int(*)(int _num,...)) (arg2);
CreateAsynEventWithDSMap = CreateAsynEventWithDSMapPtr;
CreateDsMap = CreateDsMapPtr;
bool (*DsMapAddDoublePtr)(int _index,char *_pKey,double value)= (bool(*)(int,char*,double))(arg3);
bool (*DsMapAddStringPtr)(int _index, char *_pKey, char *pVal)= (bool(*)(int,char*,char*))(arg4);
DsMapAddDouble = DsMapAddDoublePtr;
DsMapAddString = DsMapAddStringPtr;
}
But how should I pass a pointer to "CreateAsynEventWithDSMap" from GML? Where do I get those functions?
Old question, but I recently had this problem myself and spent a couple of days scratching my head, so I thought I'd post the answer for the record.
First of all the RegisterCallbacks function in the DLL needs to be __declspec (dllexport) and also extern "C", like any other function exported to GM.
Second, the RegisterCallbacks function should be defined in GM also, not just in the C/C++ file, again just like any other exported function in the extension. The four arguments should be defined as string type. It should look like this: https://i.sstatic.net/FiHjV.png
Now, RegisterCallbacks should fire automatically when you start your game, and the DsMap functions to do async stuff should work. Do not try to call RegisterCallbacks() manually.