コード例 #1
0
void DeviceListTI::GetProtocolInfoComplete(IAsync& aAsync)
{
    if (Os::TimeInMs(iEnv.OsCtx()) > iStopTimeMs) {
        return;
    }
    FunctorAsync callback = MakeFunctorAsync(*this, &DeviceListTI::GetProtocolInfoComplete);
    iConnMgr->BeginGetProtocolInfo(callback);

    Brh source;
    Brh sink;
    iConnMgr->EndGetProtocolInfo(aAsync, source, sink); // throws if invocation failed
    iLock.Wait();
    gActionCount++;
    if (sink.Bytes() == 0) {
        ASSERT(iExpectedSink.Bytes() == 0);
    }
    else {
        if (iExpectedSink.Bytes() == 0) {
            sink.TransferTo(iExpectedSink);
        }
        else {
            //ASSERT(sink == iExpectedSink);
            // can't use the above assertion.  aVia Media Renderer sometimes responds with two copies of its supported protocols
        }
    }
    iLock.Signal();
}
コード例 #2
0
ファイル: TestSubscription.cpp プロジェクト: ACDN/ohNet
void DeviceList::Poll()
{
    Functor updatesComplete = MakeFunctor(*this, &DeviceList::InitialNotificationComplete);
    const TUint count = (TUint)iList.size();
    for (TUint i=0; i<count; i++) {
        CpDevice* device = iList[i];
        TUint countBefore = gSubscriptionCount;
        Print("Device ");
        Print(device->Udn());
        CpProxyUpnpOrgConnectionManager1* connMgr = new CpProxyUpnpOrgConnectionManager1(*device);
        connMgr->SetPropertyChanged(updatesComplete);
        TUint startTime = Os::TimeInMs(iEnv.OsCtx());
        while(true) {
            iSem.Clear();
            connMgr->Subscribe();
            try {
                iSem.Wait(kDevicePollMs+1);
            }
            catch(Timeout&) {}
            connMgr->Unsubscribe();
            if (Os::TimeInMs(iEnv.OsCtx()) - startTime > kDevicePollMs) {
                break;
            }
            gSubscriptionCount++;
        }
        Print("    %u\n", gSubscriptionCount - countBefore);
        delete connMgr;
    }
}
コード例 #3
0
ファイル: TestInvocation.cpp プロジェクト: tata-/ohNet-1
void DeviceListTI::GetProtocolInfoComplete(IAsync& aAsync)
{
    if (Os::TimeInMs() > iStopTimeMs) {
        return;
    }
    FunctorAsync callback = MakeFunctorAsync(*this, &DeviceListTI::GetProtocolInfoComplete);
    iConnMgr->BeginGetProtocolInfo(callback);

    Brh source;
    Brh sink;
    iConnMgr->EndGetProtocolInfo(aAsync, source, sink); // throws if invocation failed
    iLock.Wait();
    gActionCount++;
    if (sink.Bytes() == 0) {
        ASSERT(iExpectedSink.Bytes() == 0);
    }
    else {
        if (iExpectedSink.Bytes() == 0) {
            sink.TransferTo(iExpectedSink);
        }
        else {
            ASSERT(sink == iExpectedSink);
        }
    }
    iLock.Signal();
}
コード例 #4
0
void DeviceListTI::TestSync()
{
    // trivial validation of the sync wrappers to all APIs
    // single sync call to whichever device happens to be first in our list
    if (iList.size() == 0) {
        Print("No devices found, so nothing to test\n");
        return;
    }
    CpDevice* device = iList[0];
    Print("Sync call to device ");
    Print(device->Udn());
    Print("\n");
    iConnMgr = new CpProxyUpnpOrgConnectionManager1(*device);
    Brh source;
    Brh sink;
    try {
        iConnMgr->SyncGetProtocolInfo(source, sink);
    }
    catch(ProxyError) {}
#if 0
    Print("source is ");
    Print(source);
    Print("\nsink is ");
    Print(sink);
    Print("\n");
#endif
    delete iConnMgr;
}
コード例 #5
0
void DeviceListTI::Poll()
{
    Timer timer(iEnv, MakeFunctor(*this, &DeviceListTI::TimerExpired));
    FunctorAsync callback = MakeFunctorAsync(*this, &DeviceListTI::GetProtocolInfoComplete);
    Brh tmp;
    const TUint count = (TUint)iList.size();
    for (TUint i=0; i<count; i++) {
        CpDevice* device = iList[i];
        TUint countBefore = gActionCount;
        Print("Device ");
        Print(device->Udn());
        iConnMgr = new CpProxyUpnpOrgConnectionManager1(*device);
        ASSERT(iConnMgr->Version() > 0);
        iStopTimeMs = Os::TimeInMs(iEnv.OsCtx()) + kDevicePollMs;
        timer.FireIn(kDevicePollMs);
        for (TUint j=0; j<iEnv.InitParams()->NumActionInvokerThreads(); j++) {
            iConnMgr->BeginGetProtocolInfo(callback);
        }
        iPollStop.Wait();
        Print("    %u\n", gActionCount - countBefore);
        delete iConnMgr;
        iExpectedSink.TransferTo(tmp);
    }
}