protected static void Removed(IntPtr aPtr, IntPtr aHandle) { CpDevice device = new CpDevice(aHandle); GCHandle gch = GCHandle.FromIntPtr(aPtr); CpDeviceList list = (CpDeviceList)gch.Target; if (list.iRemoved != null) { CallListChangedDelegate(list.iRemoved, list, device); } }
private static void CallListChangedDelegate(ChangeHandler aDelegate, CpDeviceList aList, CpDevice aDevice) { try { aDelegate(aList, aDevice); } catch (ProxyError e) { Console.WriteLine("WARNING: ProxyError ({0}:{1}) thrown from {2} in device list change delegate", e.Code, (e.Description != null ? e.Description : "<none>"), e.TargetSite.Name); } }
private static void CallListChangedDelegate(ChangeHandler aDelegate, CpDeviceList aList, CpDevice aDevice) { try { aDelegate(aList, aDevice); } catch (ProxyError e) { System.Diagnostics.Debug.WriteLine("WARNING: ProxyError thrown in device list change delegate: {0}", new object[] { e }); } }
private void DeviceAdded(CpDeviceList aList, CpDevice aDevice) { lock (this) { if (iDeviceList.Count == 0 && aDevice.Udn() == DeviceBasic.gDeviceName) { aDevice.AddRef(); iDeviceList.Add(aDevice); } } }
private static void CallListChangedDelegate(ChangeHandler aDelegate, CpDeviceList aList, CpDevice aDevice) { try { aDelegate(aList, aDevice); } catch (Exception e) { System.Diagnostics.Debug.WriteLine(String.Format("WARNING: Unhandled exception in device list change delegate.\n\tDevice is {0}\n\tException is {1}", aDevice.Udn(), new object[] { e })); } }
private void DeviceRemoved(CpDeviceList aList, CpDevice aDevice) { /* The device stack sends byebyes then alives for each newly enabled device. These can be interleaved with responses to a msearch and can cause tests to misbehave, thinking a device has been removed. The simplest way to work around this is to say our test guarantees that a device remains available as long as its needed then take advantage of this by ignoring device removed callbacks. */ /*lock (this) { string udn = aDevice.Udn(); int count = iDeviceList.Count; for (int i = 0; i < count; i++) { if (iDeviceList[i].Udn() == udn) { iDeviceList.RemoveAt(i); iDeviceList[i].RemoveRef(); } } }*/ }
private void DeviceRemoved(ControlPoint.CpDeviceList aList, ControlPoint.CpDevice aDevice) { lock (this) { if (!iListFrozen) { PrintDeviceInfo("Removed", aDevice); string udn = aDevice.Udn(); int count = iDeviceList.Count; for (int i = 0; i < count; i++) { if (iDeviceList[i].Udn() == udn) { iDeviceList[i].RemoveRef(); iDeviceList.RemoveAt(i); break; } } } } }
private static void CallListChangedDelegate(ChangeHandler aDelegate, CpDeviceList aList, CpDevice aDevice) { try { aDelegate(aList, aDevice); } catch (ProxyError e) { Console.WriteLine("WARNING: ProxyError ({0}:{1}) thrown from {2} in device list change delegate", e.Code, (e.Description != null ? e.Description : "<none>"), e.TargetSite.Name); } }
/// <summary> /// Create a device list that detects UPnP devices bearing a specific type of service. /// </summary> /// <param name="aDomain">Vendor domain for the target service (e.g. upnp.org).</param> /// <param name="aServiceType">Name of the target service.</param> /// <param name="aVersion">Version number for the target service.</param> /// <param name="aAdded">Delegate which will be run when a new device is detected. /// Clients who are interested this new device should call AddRef() on it and add it to some local collection. /// This callback will never be run for a device that is already in the list.</param> /// <param name="aRemoved">Delegatewhich will be run when a device is removed from the network. /// Clients who had previously stored a reference to the device in their aAdded callback should call RemoveRef() /// and remove the device from their local collection. /// Clients who had not previously claimed a reference to a device must not call ReleaseRef().</param> public ICpDeviceList CreateListServiceType( string aDomain, string aServiceType, uint aVersion, CpDeviceList.ChangeHandler aAdded, CpDeviceList.ChangeHandler aRemoved) { return new CpDeviceListUpnpServiceType(aDomain, aServiceType, aVersion, aAdded, aRemoved); }
/// <summary> /// Create a device list that detects a UPnP devices with a specific Udn. /// </summary> /// <param name="aUuid">Unique identifier for the target device.</param> /// <param name="aAdded">Delegate which will be run when a new device is detected. /// Clients who are interested this new device should call AddRef() on it and add it to some local collection. /// This callback will never be run for a device that is already in the list.</param> /// <param name="aRemoved">Delegatewhich will be run when a device is removed from the network. /// Clients who had previously stored a reference to the device in their aAdded callback should call RemoveRef() /// and remove the device from their local collection. /// Clients who had not previously claimed a reference to a device must not call ReleaseRef().</param> public ICpDeviceList CreateListUuid( string aUuid, CpDeviceList.ChangeHandler aAdded, CpDeviceList.ChangeHandler aRemoved) { return new CpDeviceListUpnpUuid(aUuid, aAdded, aRemoved); }
/// <summary> /// Create a device list that detects all UPnP root devices. /// </summary> /// <param name="aAdded">Delegate which will be run when a new device is detected. /// Clients who are interested this new device should call AddRef() on it and add it to some local collection. /// This callback will never be run for a device that is already in the list.</param> /// <param name="aRemoved">Delegatewhich will be run when a device is removed from the network. /// Clients who had previously stored a reference to the device in their aAdded callback should call RemoveRef() /// and remove the device from their local collection. /// Clients who had not previously claimed a reference to a device must not call ReleaseRef().</param> public ICpDeviceList CreateListRoot( CpDeviceList.ChangeHandler aAdded, CpDeviceList.ChangeHandler aRemoved) { return new CpDeviceListUpnpRoot(aAdded, aRemoved); }
private void DeviceRemoved(CpDeviceList aList, CpDevice aDevice) { lock (this) { string udn = aDevice.Udn(); int count = iDeviceList.Count; for (int i = 0; i < count; i++) { if (iDeviceList[i].Udn() == udn) { iDeviceList.RemoveAt(i); iDeviceList[i].RemoveRef(); } } } }
private static void CallListChangedDelegate(ChangeHandler aDelegate, CpDeviceList aList, CpDevice aDevice) { try { aDelegate(aList, aDevice); } catch (Exception e) { Console.WriteLine("WARNING: unexpected exception {0}(\"{1}\") thrown by {2}", e.GetType(), e.Message, e.TargetSite.Name); Console.WriteLine(" No exceptions should be thrown by device list change delegates"); } }
private static void CallListChangedDelegate(ChangeHandler aDelegate, CpDeviceList aList, CpDevice aDevice) { try { aDelegate(aList, aDevice); } catch (ProxyError e) { System.Diagnostics.Debug.WriteLine("WARNING: ProxyError thrown in device list change delegate: {0}", new object[] { e }); } }
void DeviceRemoved(CpDeviceList aAlist, CpDevice aAdevice) { iCallbackTracker.PreventClose(() => iListener.DeviceRemoved(aAdevice)); }