Example #1
0
        static void msearch_StatusNotifyAction(object sender, AutoEventedDiscoveryServices <Service> .StatusNotifyActionEventArgs e)
        {
            switch (e.NotifyAction)
            {
            case AutoDiscoveryServices <Service> .NotifyAction.ServiceAdded:
                var srv = e.Data as Service;

                // A new service was found, add it
                //tvUPnP.AddService((Service)(a.Data));
                break;

            case AutoDiscoveryServices <Service> .NotifyAction.DeviceRemoved:
                // A device has been removed, remove it and all services
                //tvUPnP.RemoveDevice((String)(a.Data));
                break;

            case AutoDiscoveryServices <Service> .NotifyAction.COMDeviceFound:
                var srv1 = e.Data as Service;
                Console.WriteLine(e.Data);
                break;

            case AutoDiscoveryServices <Service> .NotifyAction.ServiceRemoved:
                // A service was removed, remove it
                //tvUPnP.RemoveService((Service)(a.Data));
                break;
            }
        }
Example #2
0
        /// <summary>
        /// Occurs when the form loads.
        /// </summary>
        /// <param name="sender">The sender of the event.</param>
        /// <param name="e">The event arguments.</param>
        private void frmManagedUPnPTest_Load(object sender, System.EventArgs e)
        {
            // Setup Managed UPnP Logging
            ManagedUPnP.Logging.LogLines += new LogLinesEventHandler(Logging_LogLines);
            ManagedUPnP.Logging.Enabled   = true;

            // Create discovery for all service and device types
            mdsServices = new AutoEventedDiscoveryServices <Service>(null);

            // Try to resolve network interfaces if OS supports it
            mdsServices.ResolveNetworkInterfaces = true;

            // Assign events
            mdsServices.CanCreateServiceFor += new AutoEventedDiscoveryServices <Service> .
                                               CanCreateServiceForEventHandler(dsServices_CanCreateServiceFor);

            mdsServices.CreateServiceFor += new AutoEventedDiscoveryServices <Service> .
                                            CreateServiceForEventHandler(dsServices_CreateServiceFor);

            mdsServices.StatusNotifyAction += new AutoEventedDiscoveryServices <Service> .
                                              StatusNotifyActionEventHandler(dsServices_StatusNotifyAction);

            ManagedUPnP.WindowsFirewall.CheckUPnPFirewallRules(null);

            // Start async discovery
            mdsServices.ReStartAsync();
        }
Example #3
0
        private void button6_Click(object sender, EventArgs e)
        {
            ldDevices = new HashSet <String>();

            // Create discovery for all service and device types
            mdsServices = new AutoEventedDiscoveryServices <Service>(null);

            // Try to resolve network interfaces if OS supports it
            mdsServices.ResolveNetworkInterfaces = true;

            // Assign events
            mdsServices.CanCreateServiceFor += new AutoEventedDiscoveryServices <Service> .
                                               CanCreateServiceForEventHandler(dsServices_CanCreateServiceFor);

            mdsServices.CreateServiceFor += new AutoEventedDiscoveryServices <Service> .
                                            CreateServiceForEventHandler(dsServices_CreateServiceFor);

            mdsServices.StatusNotifyAction += new AutoEventedDiscoveryServices <Service> .
                                              StatusNotifyActionEventHandler(dsServices_StatusNotifyAction);

            ManagedUPnP.WindowsFirewall.CheckUPnPFirewallRules(null);

            // Start async discovery
            mdsServices.ReStartAsync();
        }
Example #4
0
        static void Main(string[] args)
        {
            var msearch = new AutoEventedDiscoveryServices <Service>("urn:schemas-upnp-org:device:MediaServer:1");

            msearch.StatusNotifyAction  += msearch_StatusNotifyAction;
            msearch.CanCreateServiceFor += msearch_CanCreateServiceFor;
            msearch.CreateServiceFor    += msearch_CreateServiceFor;
            msearch.ReStartAsync();

            Console.ReadLine();
        }
Example #5
0
 /// <summary>
 /// Occurs when a notify action occurs for the dicovery object.
 /// </summary>
 /// <param name="sender">The sender of the event.</param>
 /// <param name="a">The event arguments.</param>
 private void dsServices_StatusNotifyAction(object sender, AutoEventedDiscoveryServices <Service> .StatusNotifyActionEventArgs a)
 {
     switch (a.NotifyAction)
     {
     case AutoDiscoveryServices <Service> .NotifyAction.ServiceAdded:
         // A new service was found, add it
         Service s = (Service)(a.Data);
         if (ldDevices.Add(s.Device.UniqueDeviceName))
         {
             hdhrDmsDevice.Items.Add(s.Device.FriendlyName + "|" + s.Device.UniqueDeviceName.Replace("uuid:", ""));
         }
         break;
     }
 }
        /// <summary>
        /// Occurs when a notify action occurs for the dicovery object.
        /// </summary>
        /// <param name="sender">The sender of the event.</param>
        /// <param name="a">The event arguments.</param>
        private void dsServices_StatusNotifyAction(object sender, AutoEventedDiscoveryServices<Service>.StatusNotifyActionEventArgs a)
        {
            switch (a.NotifyAction)
            {
                case AutoDiscoveryServices<Service>.NotifyAction.ServiceAdded:
                    // A new service was found, add it
                    tvUPnP.AddService((Service)(a.Data));
                    break;

                case AutoDiscoveryServices<Service>.NotifyAction.DeviceRemoved:
                    // A device has been removed, remove it and all services
                    tvUPnP.RemoveDevice((String)(a.Data));
                    break;

                case AutoDiscoveryServices<Service>.NotifyAction.ServiceRemoved:
                    // A service was removed, remove it
                    tvUPnP.RemoveService((Service)(a.Data));
                    break;
            }
        }
Example #7
0
        /// <summary>
        /// Occurs when a notify action occurs for the dicovery object.
        /// </summary>
        /// <param name="sender">The sender of the event.</param>
        /// <param name="a">The event arguments.</param>
        private void dsServices_StatusNotifyAction(object sender, AutoEventedDiscoveryServices <Service> .StatusNotifyActionEventArgs a)
        {
            switch (a.NotifyAction)
            {
            case AutoDiscoveryServices <Service> .NotifyAction.ServiceAdded:
                // A new service was found, add it
                tvUPnP.AddService((Service)(a.Data));
                break;

            case AutoDiscoveryServices <Service> .NotifyAction.DeviceRemoved:
                // A device has been removed, remove it and all services
                tvUPnP.RemoveDevice((String)(a.Data));
                break;

            case AutoDiscoveryServices <Service> .NotifyAction.ServiceRemoved:
                // A service was removed, remove it
                tvUPnP.RemoveService((Service)(a.Data));
                break;
            }
        }
 /// <summary>
 /// Occurs when the discovery object wants a new auto service created.
 /// </summary>
 /// <param name="sender">The sender of the event.</param>
 /// <param name="a">The event arguments.</param>
 private void dsServices_CreateServiceFor(object sender, AutoEventedDiscoveryServices<Service>.CreateServiceForEventArgs a)
 {
     a.CreatedAutoService = a.Service;
 }
 /// <summary>
 /// Occurs when the discovery object needs to determine if an auto service can be created.
 /// </summary>
 /// <param name="sender">The sender of the event.</param>
 /// <param name="a">The event arguments.</param>
 private void dsServices_CanCreateServiceFor(object sender, AutoEventedDiscoveryServices<Service>.CanCreateServiceForEventArgs a)
 {
     a.CanCreate = true;
 }
        /// <summary>
        /// Occurs when the form loads.
        /// </summary>
        /// <param name="sender">The sender of the event.</param>
        /// <param name="e">The event arguments.</param>
        private void frmManagedUPnPTest_Load(object sender, System.EventArgs e)
        {
            // Setup Managed UPnP Logging
            ManagedUPnP.Logging.LogLines += new LogLinesEventHandler(Logging_LogLines);
            ManagedUPnP.Logging.Enabled = true;

            // Create discovery for all service and device types
            mdsServices = new AutoEventedDiscoveryServices<Service>(null);

            // Try to resolve network interfaces if OS supports it
            mdsServices.ResolveNetworkInterfaces = true;

            // Assign events
            mdsServices.CanCreateServiceFor += new AutoEventedDiscoveryServices<Service>.
                CanCreateServiceForEventHandler(dsServices_CanCreateServiceFor);

            mdsServices.CreateServiceFor += new AutoEventedDiscoveryServices<Service>.
                CreateServiceForEventHandler(dsServices_CreateServiceFor);

            mdsServices.StatusNotifyAction += new AutoEventedDiscoveryServices<Service>.
                StatusNotifyActionEventHandler(dsServices_StatusNotifyAction);

            ManagedUPnP.WindowsFirewall.CheckUPnPFirewallRules(null);

            // Start async discovery
            mdsServices.ReStartAsync();
        }
Example #11
0
 static void msearch_CanCreateServiceFor(object sender, AutoEventedDiscoveryServices <Service> .CanCreateServiceForEventArgs e)
 {
     e.CanCreate = true;
 }
Example #12
0
 /// <summary>
 /// Occurs when the discovery object needs to determine if an auto service can be created.
 /// </summary>
 /// <param name="sender">The sender of the event.</param>
 /// <param name="a">The event arguments.</param>
 private void dsServices_CanCreateServiceFor(object sender, AutoEventedDiscoveryServices <Service> .CanCreateServiceForEventArgs a)
 {
     a.CanCreate = true;
 }
Example #13
0
 /// <summary>
 /// Occurs when the discovery object wants a new auto service created.
 /// </summary>
 /// <param name="sender">The sender of the event.</param>
 /// <param name="a">The event arguments.</param>
 private void dsServices_CreateServiceFor(object sender, AutoEventedDiscoveryServices <Service> .CreateServiceForEventArgs a)
 {
     a.CreatedAutoService = a.Service;
 }
 /// <summary>
 /// Occurs when a notify action occurs for the dicovery object.
 /// </summary>
 /// <param name="sender">The sender of the event.</param>
 /// <param name="a">The event arguments.</param>
 private void dsServices_StatusNotifyAction(object sender, AutoEventedDiscoveryServices<Service>.StatusNotifyActionEventArgs a)
 {
     switch (a.NotifyAction)
     {
         case AutoDiscoveryServices<Service>.NotifyAction.ServiceAdded:
             // A new service was found, add it
             Service s = (Service)(a.Data);
             if (ldDevices.Add(s.Device.UniqueDeviceName))
             {
                 hdhrDmsDevice.Items.Add(s.Device.FriendlyName + "|" + s.Device.UniqueDeviceName.Replace("uuid:",""));
             }
             break;
     }
 }
Example #15
0
 static void msearch_CreateServiceFor(object sender, AutoEventedDiscoveryServices <Service> .CreateServiceForEventArgs e)
 {
     e.CreatedAutoService = e.Service;
 }
        private void button6_Click(object sender, EventArgs e)
        {
            ldDevices = new HashSet<String>();

            // Create discovery for all service and device types
            mdsServices = new AutoEventedDiscoveryServices<Service>(null);

            // Try to resolve network interfaces if OS supports it
            mdsServices.ResolveNetworkInterfaces = true;

            // Assign events
            mdsServices.CanCreateServiceFor += new AutoEventedDiscoveryServices<Service>.
                CanCreateServiceForEventHandler(dsServices_CanCreateServiceFor);

            mdsServices.CreateServiceFor += new AutoEventedDiscoveryServices<Service>.
                CreateServiceForEventHandler(dsServices_CreateServiceFor);

            mdsServices.StatusNotifyAction += new AutoEventedDiscoveryServices<Service>.
                StatusNotifyActionEventHandler(dsServices_StatusNotifyAction);

            ManagedUPnP.WindowsFirewall.CheckUPnPFirewallRules(null);

            // Start async discovery
            mdsServices.ReStartAsync();
        }
Example #17
0
        static void mdsServices_StatusNotifyAction(object sender, AutoEventedDiscoveryServices<Service>.StatusNotifyActionEventArgs e)
        {
            Service service;
            switch (e.NotifyAction)
            {
                case AutoDiscoveryServices<Service>.NotifyAction.ServiceAdded:
                    service = (Service)e.Data;
                    Console.WriteLine("+ Added Service: " + service.Name);
                    listServices.Add(service);
                    break;

                case AutoDiscoveryServices<Service>.NotifyAction.DeviceRemoved:
                    string device = (string)e.Data;

                    List<Service> listPendRemove = new List<Service>();
                    foreach (Service s in listServices)
                        if (s.Device.UniqueDeviceName == device)
                            listPendRemove.Add(s);

                    foreach (Service r in listPendRemove)
                        listServices.Remove(r);

                    Console.WriteLine("- Removed Device: " + device);

                    break;

                case AutoDiscoveryServices<Service>.NotifyAction.ServiceRemoved:
                    service = (Service)e.Data;
                    Console.WriteLine("- Removed Service: " + service.Name);
                    listServices.Remove(service);
                    break;
            }
        }
Example #18
0
 static void mdsServices_CreateServiceFor(object sender, AutoEventedDiscoveryServices<Service>.CreateServiceForEventArgs e)
 {
     e.CreatedAutoService = e.Service;
 }
Example #19
0
 static void mdsServices_CanCreateServiceFor(object sender, AutoEventedDiscoveryServices<Service>.CanCreateServiceForEventArgs e)
 {
     e.CanCreate = true;
 }
Example #20
0
        static void Main(string[] args)
        {
            Console.WriteLine("\n "+UPPO_LONGNAME+", (c) 2012 piksel bitworks");
            Console.Title = UPPO_LONGNAME;

            if (args.Length < 2)
            {
                Console.WriteLine("\n Usage:");
                Console.WriteLine("   uppo PORT \"DESCRIPTION\"\n");
                return;
            }

            fwPort = UInt16.Parse(args[0]);
            fwDescription = args[1];

            // Setup Managed UPnP Logging
            ManagedUPnP.Logging.LogLines += new LogLinesEventHandler(Logging_LogLines);
            ManagedUPnP.Logging.Enabled = true;

            // Create discovery for all service and device types
            mdsServices = new AutoEventedDiscoveryServices<Service>(null);

            // Try to resolve network interfaces if OS supports it
            mdsServices.ResolveNetworkInterfaces = true;

            // Assign events
            mdsServices.CanCreateServiceFor += new AutoEventedDiscoveryServices<Service>.
                CanCreateServiceForEventHandler(mdsServices_CanCreateServiceFor);

            mdsServices.CreateServiceFor += new AutoEventedDiscoveryServices<Service>.
                CreateServiceForEventHandler(mdsServices_CreateServiceFor);

            mdsServices.StatusNotifyAction += new AutoEventedDiscoveryServices<Service>.
                StatusNotifyActionEventHandler(mdsServices_StatusNotifyAction);

            Console.WriteLine("\n# Checking firewall rules...");

            ManagedUPnP.WindowsFirewall.CheckUPnPFirewallRules(null);

            mdsServices.SearchComplete += new EventHandler(mdsServices_SearchComplete);

            Console.WriteLine("\n# Scanning for UPnP devices and services...");

            // Start async discovery
            mdsServices.ReStartAsync();

            while (!done) Thread.Sleep(1000);

            #if DEBUG
            Console.WriteLine("\nPress any key to exit...");
            Console.ReadLine();
            #endif
        }