I can share my code with you, but it’s really note the best way to use it.
I’m working on another problem with my code atm, so it’s not perfect.
In any case, what I’m using it for is for async http request with a server.
With the help of the sample below and the source files, you should see how I implemented the thing
This is the code I have in my AppDelegate:
appdelegate_connector1_type callback(this, &AppDelegate::loginLoadedData); AppDelegate_Connector1* c = new AppDelegate_Connector1(); c->initWithURL(urlStr, dataString); c->callback_func = callback; this->addConnectorToStack(c);
To explain quickly, I create a base class Connector which handle/interface the request with the device.
Connector as a virtual function “execute” which is called when the request returns something.
I subclass Connector (AppDelegate_Connector1 in my case) which take a custom callback type and override “execute” to call that callback function when “execute” is called in the base class.
A better implementation to have Connector class changed into a template that takes the method/class info in it’s template and just triggered the template callback in execute.
This to avoid to have a subclass for each type of callback the connector need to use.
Hope it helps in any kind of way.