예제 #1
0
    /// <summary>
    /// Add this session to our list
    /// </summary>
    /// <param name="dpMessage"></param>
    private void SessionAdd(FindHostsResponseMessage dpMessage)
    {
        FindHostsResponseInformation dpInfo = new FindHostsResponseInformation();

        dpInfo.ApplicationDesc    = dpMessage.ApplicationDescription;
        dpInfo.device             = dpMessage.AddressDevice;
        dpInfo.sender             = dpMessage.AddressSender;
        dpInfo.RoundTripLatencyMs = dpMessage.RoundTripLatencyMs;
        dpInfo.LastFoundTime      = Environment.TickCount;

        // Let's check the items first and see if this one already exists
        bool isFound = false;

        lock (foundHosts)
        {
            for (int i = 0; i < lstSession.Items.Count; i++)
            {
                if (dpInfo.ApplicationDesc.GuidInstance == ((FindHostsResponseInformation)lstSession.Items[i]).ApplicationDesc.GuidInstance)
                {
                    foundHosts[i]       = dpInfo;
                    lstSession.Items[i] = dpInfo;
                    isFound             = true;
                }
            }
            if (!isFound)
            {
                lstSession.Items.Add(dpInfo);
                foundHosts.Add(dpInfo);
            }
        }
    }
    /// <summary>
    /// Add this session to our list
    /// </summary>
    /// <param name="dpMessage"></param>
    private void SessionAdd(FindHostsResponseMessage dpMessage)
    {
        FindHostsResponseInformation dpInfo = new FindHostsResponseInformation();

        dpInfo.ApplicationDesc = dpMessage.ApplicationDescription;
        dpInfo.device = dpMessage.AddressDevice;
        dpInfo.sender = dpMessage.AddressSender;
        dpInfo.RoundTripLatencyMs = dpMessage.RoundTripLatencyMs;
        dpInfo.LastFoundTime = Environment.TickCount;

        // Let's check the items first and see if this one already exists
        bool isFound = false;

        lock (foundHosts)
        {
            for (int i = 0; i < lstSession.Items.Count; i++)
            {
                if (dpInfo.ApplicationDesc.GuidInstance == ((FindHostsResponseInformation)lstSession.Items[i]).ApplicationDesc.GuidInstance)
                {
                    foundHosts[i] = dpInfo;
                    lstSession.Items[i] = dpInfo;
                    isFound = true;
                }
            }
            if (!isFound)
            {
                lstSession.Items.Add(dpInfo);
                foundHosts.Add(dpInfo);
            }
        }
    }