コード例 #1
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;
    }
}