OpenHome Forum
[Solved] Async Search and Query on contentDirectory C++ - Printable Version

+- OpenHome Forum (http://forum.openhome.org)
+-- Forum: OpenHome (/forumdisplay.php?fid=1)
+--- Forum: Net (/forumdisplay.php?fid=5)
+--- Thread: [Solved] Async Search and Query on contentDirectory C++ (/showthread.php?tid=1354)



[Solved] Async Search and Query on contentDirectory C++ - ChriD - 19-02-2015 10:51 PM

Hi,

This one is a common question and has literaly nothng to do with the OhNetStack i think.

In C# i can use Lamdas to add extra information for an async method
eg.

Code:
contentDirectory.Browse(..., (asyncHandle) => OnBrowseEnd(asyncHandle, 1));
contentDirectory.Browse(..., (asyncHandle) => OnBrowseEnd(asyncHandle, 2));

private void BrowseSink(IntPtr aAsyncHandle, int aOther)
{
// will be called twice with aOther has one time the value 1 and then the value 2
}

How can i do this in C++ with the OhNet AsyncFunctor?
Code:
OpenHome::Net::FunctorAsync functor = OpenHome::Net::MakeFunctorAsync(*this, &MediaServer::OnBrowseEnd);                    
this->GetContentDirectoryProxy()->BeginBrowse(_containerId, browseFlag, "*", 0, 0, "", functor);
Is this possible?

best regards
Chris


RE: Async Search and Query on contentDirectory C++ - simonc - 20-02-2015 09:12 AM

It isn't possible to use lambdas in place of FunctorAsync I'm afraid. While I do understand the attraction of this, it's unlikely we'll support this soon. Use of lambdas requires a compiler with support for C++11 - some clients of ohNet run on NASes that use relatively old versions of Linux whose compilers do not support C++11.


RE: Async Search and Query on contentDirectory C++ - ChriD - 20-02-2015 05:34 PM

Okay Sad Thats a pity
So there is no chance to know which async method triggered the callback? Not any async handler id or something like that?

Would be nice, but all in all no problem. I can solve my Problem by using threads and call the sync method and make my own callbacks