Closed lbussy closed 4 years ago
ETA: Just to be clear - my callback is common for all requests. It's the method which sets the callback which is different.
I saw that while digging, but I guess I was holding my mouth wrong when I tried it. I'll continue poking to see if I can make it work. I think I only saw the one example in the repo - is that right?
ETA: Aha, you typed more while I was replying! Thank you sir.
Just deleted that comment. It's actually easier.
The callback has the pointer to the instance of asyncHTTPrequest.
typedef std::function<void(void*, asyncHTTPrequest*, size_t available)> onDataCB;
The void* first parameter is extra and is the value you pass when registering the callback. Use it for whatever you need. If you need to pass more than one value, then pass a pointer to a structure with everythiong you need.
I set a callback with onData() and then process the return in the callback. I have more than one method calling asynch events and I was wondering if there's a good way to identify the method which set the callback?