/// <summary> /// Raises the DeviceAdded event. /// </summary> /// <param name="e">The event arguments.</param> protected virtual void OnServiceAdded(ServiceAddedEventArgs e) { if (ServiceAdded != null) { ServiceAdded.GetInvocationList().InvokeEventGUIThreadSafe(this, e); } }
private void OnServiceAdded(object sender, ServiceAddedEventArgs e) { if (e.Service.Device.ManufacturerName == "Sonos, Inc.") { e.Service.StateVariableChanged += ServiceOnStateVariableChanged; if (e.Service.ServiceTypeIdentifier == "urn:schemas-upnp-org:service:RenderingControl:1") { var device = GetSonosDevice(e.Service); var room = Rooms.SingleOrDefault(r => r.Name == device.RoomName); if (room == null) { var newRoom = new Room { Name = device.RoomName }; Rooms.Add(newRoom); if (RoomFound != null) { RoomFound(newRoom); } newRoom.AddDevice(device); } else { room.AddDevice(device); } } } }
private void OnNewService(object sender, ServiceAddedEventArgs e) { WebSocketServiceHost wssh = null; foreach (WebSocketServiceHost cwssh in this.Server.WebSocketServices.Hosts) { if (cwssh.Path == e.Path) { wssh = cwssh; } } if (wssh != null) { VebSocketService s = new VebSocketService(this.HDEHost, wssh); this.Services.Add(e.Path, s); } }
/// <summary> /// Occurs when the UPnPDiscovery component finds a new service. /// </summary> /// <param name="sender">The sender of the event.</param> /// <param name="a">The event arguments.</param> private void UPnP_ServiceAdded(object sender, ServiceAddedEventArgs a) { // Notify user WriteLine(String.Format("Service Found: '{0}' - {1} - {2}", a.Service.Id, a.Service.Name, a.Service.ServiceTypeIdentifier)); // If the service is a WANIPConnection service (any version) if (a.Service.ServiceTypeIdentifier.Contains(":WANIPConnection:")) { // Set the service msWANIPConnectionService = a.Service; // Update buttons enabled properties UpdateEnabled(); // Notify user we have found the service WriteLine("[Service Located]"); } }
/// <summary> /// Raises the DeviceAdded event. /// </summary> /// <param name="e">The event arguments.</param> protected virtual void OnServiceAdded(ServiceAddedEventArgs e) { if (ServiceAdded != null) ServiceAdded.GetInvocationList().InvokeEventGUIThreadSafe(this, e); }