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; } }
void CpDevices::Clear() { iLock.Wait(); const TUint count = (TUint)iList.size(); for (TUint i=0; i<count; i++) { iList[i]->RemoveRef(); } iList.clear(); (void)iSem.Clear(); iLock.Signal(); }
void SuiteMulticast::Test() { iThread0->Start(); iThread1->Start(); iSender.Wait(); iSender.Wait(); SocketUdp send; Bwn buf(iExp); TUint i; for( i=0; i < kMsgBytes; i++) { buf.SetBytes(0); AppendUint32(buf, i); //num of bytes in this message buf.SetBytes(i + sizeof(TUint)); //use prefilled values send.Send(buf, Endpoint(iPort, kMulticastAddress)); // assume that a delay of 500ms without response implies that the message wasn't delivered try { iSender.Wait(500); iSender.Wait(500); } catch (Timeout&) { Print("SuiteMulticast - message(s) not delivered\n"); TEST(1 == 0); return; // temp } if (iSender.Clear()) { TEST(1 == 0); Print("SuiteMulticast - sent one message, received more than once\n"); } } buf.SetBytes(0); AppendUint32(buf, kQuit); send.Send(buf, Endpoint(iPort, kMulticastAddress)); try { iSender.Wait(500); iSender.Wait(500); } catch (Timeout&) { Print("SuiteMulticast - quit message(s) not delivered\n"); } }