xamarin Posted February 11, 2014 Share Posted February 11, 2014 Hello, This is my first post here, I'm trying to write a simple java code , that detects upnp devices and display them. could you please give me hand to be able to continue ?! Link to comment
xamarin Posted February 12, 2014 Author Share Posted February 12, 2014 Hello again, finally i have a java class that helps me displaying upnp devices , it displays the services of the device too, but no actions found for the services , System.out.println(services.hasActions()) return false, it is weird , any ideas ? package fr.enssat.fgt.upnp.control; import org.teleal.cling.UpnpService; import org.teleal.cling.UpnpServiceImpl; import org.teleal.cling.model.message.header.STAllHeader; import org.teleal.cling.model.meta.Action; import org.teleal.cling.model.meta.LocalDevice; import org.teleal.cling.model.meta.RemoteDevice; import org.teleal.cling.model.meta.Service; import org.teleal.cling.registry.Registry; import org.teleal.cling.registry.RegistryListener; /** * Runs a simple UPnP discovery procedure. * http://4thline.org/projects/cling/core/manual/cling-core-manual.html */ public class Test { public static void main(String[] args) throws Exception { // UPnP discovery is asynchronous, we need a callback RegistryListener listener = new RegistryListener() { public void remoteDeviceDiscoveryStarted(Registry registry, RemoteDevice device) { System.out.println( "Discovery started: " + device.getDisplayString() ); Service[] services = device.getServices(); for(int i=0;i System.out.println(services[i].hasActions()); } } public void remoteDeviceDiscoveryFailed(Registry registry, RemoteDevice device, Exception ex) { System.out.println( "Discovery failed: " + device.getDisplayString() + " => " + ex ); } public void remoteDeviceAdded(Registry registry, RemoteDevice device) { System.out.println( "Remote device available: " + device.getServices().toString() ); } public void remoteDeviceUpdated(Registry registry, RemoteDevice device) { System.out.println( "Remote device updated: " + device.getDisplayString() ); } public void remoteDeviceRemoved(Registry registry, RemoteDevice device) { System.out.println( "Remote device removed: " + device.getDisplayString() ); } public void localDeviceAdded(Registry registry, LocalDevice device) { System.out.println( "Local device added: " + device.getDisplayString() ); } public void localDeviceRemoved(Registry registry, LocalDevice device) { System.out.println( "Local device removed: " + device.getDisplayString() ); } public void beforeShutdown(Registry registry) { System.out.println( "Before shutdown, the registry has devices: " + registry.getDevices().size() ); } public void afterShutdown() { System.out.println("Shutdown of registry complete!"); } }; // This will create necessary network resources for UPnP right away System.out.println("Starting Cling..."); UpnpService upnpService = new UpnpServiceImpl(listener); // Send a search message to all devices and services, they should respond soon upnpService.getControlPoint().search(new STAllHeader()); // Let's wait 10 seconds for them to respond System.out.println("Waiting 10 seconds before shutting down..."); Thread.sleep(10000); // Release all resources and advertise BYEBYE to other UPnP devices System.out.println("Stopping Cling..."); upnpService.shutdown(); } } Link to comment
Michel Kohanim Posted February 12, 2014 Share Posted February 12, 2014 Hi xamarin, I do not think anyone here would be able to help you with your project. I am sorry. With kind regards, Michel Link to comment
Recommended Posts