RoMote icon indicating copy to clipboard operation
RoMote copied to clipboard

Can not find device even phone connect to same wifi network

Open nvThanh opened this issue 3 years ago • 1 comments

The app pending at finding device ( other app take 1 sec to found device ),

nvThanh avatar Mar 09 '21 14:03 nvThanh

private String scanForRoku(URL url) throws IOException { byte[] sendData = new byte[1024]; byte[] receiveData = new byte[1024]; String MSEARCH = "M-SEARCH * HTTP/1.1\nHost: " + url.getHost() + ":" + url.getPort() + "\nMan: "ssdp:discover"\nST: roku:ecp\n"; sendData = MSEARCH.getBytes(); DatagramPacket sendPacket = new DatagramPacket(sendData, sendData.length, InetAddress.getByName(url.getHost()), url.getPort()); DatagramSocket clientSocket = new DatagramSocket(); clientSocket.send(sendPacket); DatagramPacket receivePacket = new DatagramPacket(receiveData, receiveData.length); clientSocket.receive(receivePacket); String response = new String(receivePacket.getData()); clientSocket.close(); response = response.toLowerCase(); String address = response.split("location:")[1].split("\n")[0].split("http://")[1].split(":")[0].trim(); return address; }

its stuck in here, maybe you run more than 1 thread at the same time

nvThanh avatar Mar 09 '21 15:03 nvThanh