Example #1
0
/*----------------------------------------------------------------------
|   PLT_SsdpDeviceAnnounceUnicastTask::DoRun
+---------------------------------------------------------------------*/
void
PLT_SsdpDeviceAnnounceTask::DoRun()
{
    NPT_Result res = NPT_SUCCESS;
    NPT_List<NPT_NetworkInterface*> if_list;

    while (1) {
        NPT_CHECK_LABEL_FATAL(PLT_UPnPMessageHelper::GetNetworkInterfaces(if_list),
                              cleanup);

        // if we're announcing our arrival, sends a byebye first (NMPR compliance)
        if (m_IsByeByeFirst == true) {
            m_IsByeByeFirst = false;
            res = if_list.Apply(PLT_SsdpAnnounceInterfaceIterator(m_Device, true, m_IsBroadcast));
            if (NPT_FAILED(res)) goto cleanup;

            // schedule to announce alive in 300 ms
            if (NPT_FAILED(res) || IsAborting((NPT_Timeout)300)) break;
        }
            
        res = if_list.Apply(PLT_SsdpAnnounceInterfaceIterator(m_Device, false, m_IsBroadcast));
        
cleanup:
        if_list.Apply(NPT_ObjectDeleter<NPT_NetworkInterface>());
        if_list.Clear();

        if (NPT_FAILED(res) || IsAborting(m_Repeat.m_Seconds*1000)) break;
    };
}
Example #2
0
/*----------------------------------------------------------------------
|   PLT_SsdpDeviceAnnounceUnicastTask::DoRun
+---------------------------------------------------------------------*/
void
PLT_SsdpDeviceAnnounceTask::DoRun()
{
    NPT_List<NPT_NetworkInterface*> if_list;

    while (1) {
        NPT_CHECK_LABEL_FATAL(PLT_UPnPMessageHelper::GetNetworkInterfaces(if_list, false),
                              cleanup);

        // if we're announcing our arrival, sends a byebye first (NMPR compliance)
        if (m_IsByeByeFirst == true) {
            m_IsByeByeFirst = false;
            
            if (m_ExtraBroadcast) {
                if_list.Apply(PLT_SsdpAnnounceInterfaceIterator(m_Device, true, m_ExtraBroadcast));
            }
            
            // multicast now
            if_list.Apply(PLT_SsdpAnnounceInterfaceIterator(m_Device, true, false));
            
            // schedule to announce alive in 200 ms
            if (IsAborting(200)) break;
        }
        
        if (m_ExtraBroadcast) {
            if_list.Apply(PLT_SsdpAnnounceInterfaceIterator(m_Device, false, m_ExtraBroadcast));
        }
        
        // multicast now
        if_list.Apply(PLT_SsdpAnnounceInterfaceIterator(m_Device, false, false));
        
        
cleanup:
        if_list.Apply(NPT_ObjectDeleter<NPT_NetworkInterface>());
        if_list.Clear();

        if (IsAborting((NPT_Timeout)m_Repeat.ToMillis())) break;
    };
}