本文整理汇总了C++中DviSubscription::Sid方法的典型用法代码示例。如果您正苦于以下问题:C++ DviSubscription::Sid方法的具体用法?C++ DviSubscription::Sid怎么用?C++ DviSubscription::Sid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DviSubscription
的用法示例。
在下文中一共展示了DviSubscription::Sid方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Subscribe
void DviSessionUpnp::Subscribe()
{
LOG(kDvEvent, "Subscription request from ");
iHeaderCallback.Log();
LOG(kDvEvent, "\n");
if (iHeaderSid.Received()) {
Renew();
return;
}
if (!iHeaderCallback.Received() || !iHeaderNt.Received() || !iHeaderTimeout.Received()) {
Error(HttpStatus::kPreconditionFailed);
}
DviDevice* device;
DviService* service;
ParseRequestUri(DviProtocolUpnp::kEventUrlTail, &device, &service);
if (device == NULL || service == NULL) {
Error(HttpStatus::kPreconditionFailed);
}
TUint duration = iHeaderTimeout.Timeout();
Brh sid;
device->CreateSid(sid);
SubscriptionDataUpnp* data = new SubscriptionDataUpnp(iHeaderCallback.Endpoint(), iHeaderCallback.Uri());
DviSubscription* subscription = new DviSubscription(*device, *iPropertyWriterFactory, data, sid, duration);
iPropertyWriterFactory->SubscriptionAdded(*subscription);
DviSubscriptionManager::AddSubscription(*subscription);
if (iHeaderExpect.Continue()) {
iWriterResponse->WriteStatus(HttpStatus::kContinue, Http::eHttp11);
iWriterResponse->WriteFlush();
}
// respond to subscription request
iResponseStarted = true;
iWriterResponse->WriteStatus(HttpStatus::kOk, Http::eHttp11);
WriteServerHeader(*iWriterResponse);
IWriterAscii& writerSid = iWriterResponse->WriteHeaderField(HeaderSid::kHeaderSid);
writerSid.Write(HeaderSid::kFieldSidPrefix);
writerSid.Write(subscription->Sid());
writerSid.WriteFlush();
IWriterAscii& writerTimeout = iWriterResponse->WriteHeaderField(HeaderTimeout::kHeaderTimeout);
writerTimeout.Write(HeaderTimeout::kFieldTimeoutPrefix);
writerTimeout.WriteUint(duration);
writerTimeout.WriteFlush();
iWriterResponse->WriteHeader(Http::kHeaderConnection, Http::kConnectionClose);
iWriterResponse->WriteFlush();
iResponseEnded = true;
LOG(kDvEvent, "Subscription complete for ");
iHeaderCallback.Log();
LOG(kDvEvent, ", sid is ");
LOG(kDvEvent, subscription->Sid());
LOG(kDvEvent, "\n");
// Start subscription, prompting delivery of the first update (covering all state variables)
service->AddSubscription(subscription);
}
示例2: Subscribe
TUint CpiDeviceDv::Subscribe(CpiSubscription& aSubscription, const OpenHome::Uri& /*aSubscriber*/)
{
Brh sid;
iDeviceDv.CreateSid(sid);
Brn tmp(sid);
Brh transfer(tmp);
aSubscription.SetSid(transfer);
TUint durationSecs = iDeviceCp->GetCpStack().Env().InitParams()->SubscriptionDurationSecs();
DviSubscription* subscriptionDv = new DviSubscription(iDeviceDv.GetDvStack(), iDeviceDv, *this, NULL, sid);
subscriptionDv->AddRef(); // guard against subscription expiring before client tries to renew or unsubscribe
iDeviceDv.GetDvStack().SubscriptionManager().AddSubscription(*subscriptionDv);
subscriptionDv->SetDuration(durationSecs);
iLock.Wait();
if (iSubscriptions.size() == 0) {
iShutdownSem.Wait(); // consume shutdown signal now the map is non-empty
}
Brn sid2(subscriptionDv->Sid());
Subscription* subscription = new Subscription(aSubscription, subscriptionDv);
iSubscriptions.insert(std::pair<Brn,Subscription*>(sid2, subscription));
iDeviceCp->AddRef();
iLock.Signal();
DviService* service = iDeviceDv.ServiceReference(aSubscription.ServiceType());
ASSERT(service != NULL);
service->AddSubscription(subscriptionDv);
service->RemoveRef();
return durationSecs;
}
示例3: AddSubscription
void DviSubscriptionManager::AddSubscription(DviSubscription& aSubscription)
{
iLock.Wait();
Brn sid(aSubscription.Sid());
iMap.insert(std::pair<Brn,DviSubscription*>(sid, &aSubscription));
iLock.Signal();
}
示例4: SubscriptionAdded
void PropertyWriterFactory::SubscriptionAdded(DviSubscription& aSubscription)
{
iSubscriptionMapLock.Wait();
Brn sidBuf(aSubscription.Sid());
iSubscriptionMap.insert(std::pair<Brn,DviSubscription*>(sidBuf, &aSubscription));
iSubscriptionMapLock.Signal();
AddRef();
}
示例5: RemoveSubscription
void DviSubscriptionManager::RemoveSubscription(DviSubscription& aSubscription)
{
iLock.Wait();
Brn sid(aSubscription.Sid());
Map::iterator it = iMap.find(sid);
if (it != iMap.end()) {
iMap.erase(it);
}
iLock.Signal();
}
示例6: RemoveSubscription
void DviService::RemoveSubscription(const Brx& aSid)
{
iLock.Wait();
for (TUint i=0; i<iSubscriptions.size(); i++) {
DviSubscription* subscription = iSubscriptions[i];
if (subscription->Sid() == aSid) {
DviSubscriptionManager::RemoveSubscription(*subscription);
iSubscriptions.erase(iSubscriptions.begin() + i);
iLock.Signal();
subscription->RemoveRef();
return;
}
}
iLock.Signal();
}
示例7: DoUnsubscribe
void DviSessionLpec::DoUnsubscribe(TUint aIndex, TBool aRespond)
{
DviSubscription* subscription = iSubscriptions[aIndex].Subscription();
ASSERT(subscription != NULL);
iSubscriptions[aIndex].Service().RemoveSubscription(subscription->Sid());
if (aRespond) {
AutoMutex a(iWriteLock);
iResponseStarted = true;
iWriteBuffer->Write(Lpec::kMethodUnsubscribe);
iWriteBuffer->Write(' ');
Bws<Ascii::kMaxUintStringBytes> lpecSidBuf;
(void)Ascii::AppendDec(lpecSidBuf, iSubscriptions[aIndex].LpecSid());
iWriteBuffer->Write(lpecSidBuf);
iWriteBuffer->Write(Lpec::kMsgTerminator);
iWriteBuffer->WriteFlush();
iResponseEnded = true;
}
iSubscriptions.erase(iSubscriptions.begin()+aIndex);
}
示例8: Subscribe
void DviProviderSubscriptionLongPoll::Subscribe(IDvInvocation& aInvocation, const Brx& aClientId, const Brx& aUdn, const Brx& aService, TUint aRequestedDuration,
IDvInvocationResponseString& aSid, IDvInvocationResponseUint& aDuration)
{
if (aRequestedDuration > kTimeoutLongPollSecs) {
aRequestedDuration = kTimeoutLongPollSecs;
}
DviDevice* device = iDvStack.DeviceMap().Find(aUdn);
if (device == NULL) {
aInvocation.Error(kErrorCodeBadDevice, kErrorDescBadDevice);
}
DviService* service = NULL;
const TUint serviceCount = device->ServiceCount();
for (TUint i=0; i<serviceCount; i++) {
DviService* s = &device->Service(i);
if (s->ServiceType().PathUpnp() == aService) {
service = s;
break;
}
}
if (service == NULL) {
aInvocation.Error(kErrorCodeBadService, kErrorDescBadService);
}
Brh sid;
device->CreateSid(sid);
TUint timeout = aRequestedDuration;
DviSubscription* subscription = new DviSubscription(iDvStack, *device, iPropertyUpdateCollection, NULL, sid, timeout);
aInvocation.StartResponse();
aSid.Write(subscription->Sid());
aSid.WriteFlush();
aDuration.Write(timeout);
aInvocation.EndResponse();
// Start subscription, prompting availability of the first update (covering all state variables)
iPropertyUpdateCollection.AddSubscription(aClientId, subscription);
iDvStack.SubscriptionManager().AddSubscription(*subscription);
service->AddSubscription(subscription);
}