public static void Main(string[] args) { Console.WriteLine("Hello World!"); var controlPoint = new UpnpSmartControlPoint(); controlPoint.OnAddedDevice += controPoint_OnAddedDevice; controlPoint.OnRemovedDevice += controPoint_OnRemovedDevice; controlPoint.OnDeviceExpired += controPoint_OnDeviceExpired; while (true) { //Thread.Sleep(1000); //Console.WriteLine("."); var s = Console.ReadLine(); if (s == "-" && controlPoint != null) { StopControlPoint(controlPoint); } if (s == "+") { StartControlPoint(controlPoint); } if (s == "s") { // Simulate WeMo Switch AddWeMoSwitch(); } } }
public static void Main(string[] args) { Console.WriteLine("Hello World!"); var controlPoint = new UpnpSmartControlPoint(); controlPoint.OnAddedDevice += controPoint_OnAddedDevice; controlPoint.OnRemovedDevice += controPoint_OnRemovedDevice; controlPoint.OnDeviceExpired += controPoint_OnDeviceExpired; while (true) { //Thread.Sleep(1000); //Console.WriteLine("."); var s = Console.ReadLine(); if (s == "-" && controlPoint != null) { controlPoint.ShutDown(); controlPoint.OnAddedDevice -= controPoint_OnAddedDevice; controlPoint.OnRemovedDevice -= controPoint_OnRemovedDevice; controlPoint.OnDeviceExpired -= controPoint_OnDeviceExpired; controlPoint = null; } if (s == "+") { controlPoint = new UpnpSmartControlPoint(); controlPoint.OnAddedDevice += controPoint_OnAddedDevice; controlPoint.OnRemovedDevice += controPoint_OnRemovedDevice; controlPoint.OnDeviceExpired += controPoint_OnDeviceExpired; } } }
private static void StopControlPoint(UpnpSmartControlPoint controlPoint) { controlPoint.ShutDown(); controlPoint.OnAddedDevice -= controPoint_OnAddedDevice; controlPoint.OnRemovedDevice -= controPoint_OnRemovedDevice; controlPoint.OnDeviceExpired -= controPoint_OnDeviceExpired; controlPoint = null; }
private static void StartControlPoint(UpnpSmartControlPoint controlPoint) { StopControlPoint(controlPoint); controlPoint = new UpnpSmartControlPoint(); controlPoint.OnAddedDevice += controPoint_OnAddedDevice; controlPoint.OnRemovedDevice += controPoint_OnRemovedDevice; controlPoint.OnDeviceExpired += controPoint_OnDeviceExpired; }
private static void controPoint_OnRemovedDevice(UpnpSmartControlPoint sender, UPnPDevice device) { Console.WriteLine("Removed " + device.FriendlyName); }
private static void controPoint_OnDeviceExpired(UpnpSmartControlPoint sender, UPnPDevice device) { Console.WriteLine("Expired " + device.FriendlyName); }