From 98e52c47474e91dcaa5d41d8fd4925b17689fd65 Mon Sep 17 00:00:00 2001 From: "Andrzej J.R. Hunt" Date: Fri, 3 Aug 2012 10:50:43 +0200 Subject: Hostname transfer implemented. Change-Id: I92f2a3c00215491b6f24d52b922a4e4f2c461637 --- .../impressremote/communication/ServerFinder.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'android') diff --git a/android/sdremote/src/org/libreoffice/impressremote/communication/ServerFinder.java b/android/sdremote/src/org/libreoffice/impressremote/communication/ServerFinder.java index b8ba315c4f76..5ce7897e2d0c 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/communication/ServerFinder.java +++ b/android/sdremote/src/org/libreoffice/impressremote/communication/ServerFinder.java @@ -39,7 +39,7 @@ public class ServerFinder { try { String aCommand = null; - String aAddress = null; + String aName = null; System.out.println("SF:listening for packet\n"); mSocket.receive(aPacket); System.out.println("SF:received packet\n"); @@ -53,11 +53,24 @@ public class ServerFinder { if (i == aBuffer.length || !aCommand.equals("LOREMOTE_ADVERTISE")) { return; } + for (int j = i; j < aBuffer.length; j++) { + if (aPacket.getData()[i] == '\n') { + aName = new String(aPacket.getData(), i + 1, j, CHARSET); + break; + } + } + if (aName == null) { + return; + } Server aServer = new Server(CommunicationService.Protocol.NETWORK, - aPacket.getAddress().toString(), "NONAME", + aPacket.getAddress().toString(), aName, System.currentTimeMillis()); mServerList.add(aServer); + // System.out.println("SF FOUND: IP=" + // + aPacket.getAddress().toString() + " HOSTNAME=" + // + aName); + Intent aIntent = new Intent( CommunicationService.MSG_SERVERLIST_CHANGED); LocalBroadcastManager.getInstance(mContext).sendBroadcast(aIntent); -- cgit