Example #1
0
        /// <summary>
        /// Handles the ServiceFound event of the agent control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Acn.Slp.ServiceFoundEventArgs"/> instance containing the event data.</param>
        void agent_ServiceFound(object sender, ServiceFoundEventArgs e)
        {
            foreach (UrlEntry url in e.Urls)
            {
                bool newDevice = false;
                SlpDeviceInformation device;
                lock (devicesLock)
                {
                    if (!devices.TryGetValue(url.Url, out device))
                    {
                        device = new SlpDeviceInformation()
                        {
                            Url = url.Url, FirstUpdateId = e.RequestId
                        };
                        devices[url.Url] = device;
                    }

                    device.Endpoint = e.Address;
                    device.DiscoveryAgents.Add(sender as SlpUserAgent);
                    device.UpdateRecieved(e.RequestId);
                }

                RequestAttributes(device);
                if (newDevice)
                {
                    OnDeviceStateChange(device);
                }
            }
            OnDevicesUpdated();
        }
Example #2
0
 /// <summary>
 /// Called when a device state changes.
 /// </summary>
 /// <param name="device">The device.</param>
 protected virtual void OnDeviceStateChange(SlpDeviceInformation device)
 {
     if (DeviceStateChange != null)
     {
         DeviceStateChange(this, new SlpDeviceEventArgs()
         {
             Device = device
         });
     }
 }
Example #3
0
 /// <summary>
 /// Requests the attributes for a device.
 /// </summary>
 /// <param name="device">The device.</param>
 private void RequestAttributes(SlpDeviceInformation device)
 {
     if (FetchAttributes && device.DiscoveryAgents.Count > 0)
     {
         SlpUserAgent agent     = device.DiscoveryAgents.First();
         int          requestId = agent.RequestAttributes(device.Endpoint, device.Url);
         lock (attributeRequestLog)
         {
             attributeRequestLog[new UserAgentRequest(agent, requestId)] = device;
         }
     }
 }