Beispiel #1
0
// ################################
// ############# SSDP #############
// ################################

#region SSDP

	// Call with: "" for root devices; null for all devices; Any other input for specific search
	public static async Task<Dictionary<string,Rssdp.DiscoveredSsdpDevice>> SearchForDevicesType( string type){

		if( type == null )
			DebugStream.outPut += "Searching for all devices...\n";

		else if( type == "" )
			DebugStream.outPut += "Searching for root devices...\n";

		else
			DebugStream.outPut += "Searching for \"" + type + "\" devices...\n";

		IEnumerable<Rssdp.DiscoveredSsdpDevice> results = null;

		using( var deviceLocator = new Rssdp.SsdpDeviceLocator() ){

			if( type != null )
				results = await deviceLocator.SearchAsync(type == "" ? Rssdp.Infrastructure.SsdpConstants.UpnpDeviceTypeRootDevice : type);
			else
				results = await deviceLocator.SearchAsync();
		}

		// ################################
		foreach( var device in results)
			DebugStream.outPut += device.ResponseHeaders.ToString() + "\n";

		return results.ToDictionary(dev => dev.Usn.Substring(5,36),dev => dev);
	}
Beispiel #2
0
        private static async void SearchAsync()
        {
            Console.WriteLine("Searching");
            var locator = new Rssdp.SsdpDeviceLocator(new Rssdp.Infrastructure.SsdpCommunicationsServer(new Rssdp.SocketFactory("192.168.1.57")));
            var results = await locator.SearchAsync();

            foreach (var device in results)
            {
                Console.WriteLine(device.Usn + " " + device.DescriptionLocation);
            }
            Console.WriteLine("Done. Press any key to exit.");
        }
Beispiel #3
0
        public async Task <IEnumerable <Rssdp.DiscoveredSsdpDevice> > SearchAsync()
        {
            var locator = new Rssdp.SsdpDeviceLocator();

            return(await locator.SearchAsync());
        }