Esempio n. 1
0
SsdpListenerMulticast::SsdpListenerMulticast(Environment& aEnv, TIpAddress aInterface)
    : SsdpListener("SsdpListenerM")
    , iEnv(aEnv)
    , iLock("LMCM")
    , iNextHandlerId(0)
    , iInterface(aInterface)
    , iSocket(aEnv, aInterface, Endpoint(Ssdp::kMulticastPort, Ssdp::kMulticastAddress))
    , iBuffer(iSocket)
    , iReaderUntil(iBuffer)
    , iReaderRequest(aEnv, iReaderUntil)
    , iExiting(false)
    , iRecreateSocket(false)
{
    try
    {
        iSocket.SetRecvBufBytes(kRecvBufBytes);
    }
    catch (NetworkError&) {
    }
    aEnv.AddResumeObserver(*this);

    iReaderRequest.AddHeader(iHeaderHost);
    iReaderRequest.AddHeader(iHeaderCacheControl);
    iReaderRequest.AddHeader(iHeaderLocation);
    iReaderRequest.AddHeader(iHeaderNt);
    iReaderRequest.AddHeader(iHeaderNts);
    iReaderRequest.AddHeader(iHeaderServer);
    iReaderRequest.AddHeader(iHeaderUsn);
    iReaderRequest.AddHeader(iHeaderMan);
    iReaderRequest.AddHeader(iHeaderMx);
    iReaderRequest.AddHeader(iHeaderSt);
    iReaderRequest.AddMethod(Ssdp::kMethodNotify);
    iReaderRequest.AddMethod(Ssdp::kMethodMsearch);
}
Esempio n. 2
0
SsdpListenerUnicast::SsdpListenerUnicast(Environment& aEnv, ISsdpNotifyHandler& aNotifyHandler, TIpAddress aInterface)
    : SsdpListener("SsdpListenerU")
    , iEnv(aEnv)
    , iNotifyHandler(aNotifyHandler)
    , iInterface(aInterface)
    , iSocket(aEnv, 0, aInterface)
    , iSocketWriter(iSocket, Endpoint(Ssdp::kMulticastPort, Ssdp::kMulticastAddress))
    , iSocketReader(iSocket)
    , iWriteBuffer(iSocketWriter)
    , iWriter(iWriteBuffer)
    , iReadBuffer(iSocketReader)
    , iReaderUntil(iReadBuffer)
    , iReaderResponse(aEnv, iReaderUntil)
    , iWriterLock("SSLU")
    , iExiting(false)
    , iRecreateSocket(false)
{
    try {
        iSocket.SetMulticastIf(aInterface);
    }
    catch (NetworkError&) {} // risk startup crashes if we don't suppress errors here
    iSocket.SetTtl(aEnv.InitParams()->MsearchTtl());
    try {
        iSocket.SetRecvBufBytes(kRecvBufBytes);
    }
    catch (NetworkError&) {}
    aEnv.AddResumeObserver(*this);
    
    iReaderResponse.AddHeader(iHeaderCacheControl);
    iReaderResponse.AddHeader(iHeaderExt);
    iReaderResponse.AddHeader(iHeaderLocation);
    iReaderResponse.AddHeader(iHeaderServer);
    iReaderResponse.AddHeader(iHeaderSt);
    iReaderResponse.AddHeader(iHeaderUsn);
}