From ad72b47df44b6ac73a0b76b346d5e93811e6941f Mon Sep 17 00:00:00 2001 From: "Andrzej J.R. Hunt" Date: Fri, 3 Aug 2012 14:18:41 +0200 Subject: [PATCH] Detect duplicates when finding servers. Change-Id: Ie922e1f930df7987f77c153474aece2668250293 --- .../impressremote/communication/ServerFinder.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/android/sdremote/src/org/libreoffice/impressremote/communication/ServerFinder.java b/android/sdremote/src/org/libreoffice/impressremote/communication/ServerFinder.java index c30f9c25085d..c47ce805e36a 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/communication/ServerFinder.java +++ b/android/sdremote/src/org/libreoffice/impressremote/communication/ServerFinder.java @@ -6,7 +6,7 @@ import java.net.DatagramPacket; import java.net.DatagramSocket; import java.net.InetAddress; import java.net.SocketException; -import java.util.Vector; +import java.util.HashMap; import org.libreoffice.impressremote.communication.CommunicationService.Server; @@ -27,7 +27,7 @@ public class ServerFinder { private boolean mFinishRequested = false; - private Vector mServerList = new Vector(); + private HashMap mServerList = new HashMap(); public ServerFinder(Context aContext) { mContext = aContext; @@ -65,7 +65,7 @@ public class ServerFinder { Server aServer = new Server(CommunicationService.Protocol.NETWORK, aPacket.getAddress().toString(), aName, System.currentTimeMillis()); - mServerList.add(aServer); + mServerList.put(aServer.getAddress(), aServer); // System.out.println("SF FOUND: IP=" // + aPacket.getAddress().toString() + " HOSTNAME=" @@ -135,6 +135,6 @@ public class ServerFinder { } public Server[] getServerList() { - return mServerList.toArray(new Server[mServerList.size()]); + return mServerList.entrySet().toArray(new Server[mServerList.size()]); } }