aboutsummaryrefslogtreecommitdiff
path: root/src/ProxyMaster.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/ProxyMaster.java')
-rw-r--r--src/ProxyMaster.java20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/ProxyMaster.java b/src/ProxyMaster.java
index 9d40ebb..8ac1d10 100644
--- a/src/ProxyMaster.java
+++ b/src/ProxyMaster.java
@@ -7,6 +7,8 @@
* (c) ENAC
*
* changelog:
+ * 1.2.16
+ * - switches from Vector to proper collections
* 1.2.14
* - throws RuntimeException instead of System.exit(), allows code reuse
* - switch from gnu regexp (deprecated) to the built in java regexp
@@ -19,7 +21,11 @@ package fr.dgac.ivy.tools ; // TODO go into sub tools, and build a shell/.BAT sc
import fr.dgac.ivy.* ;
import java.io.*;
import java.net.*;
-import java.util.* ;
+import java.util.Map ;
+import java.util.HashMap ;
+import java.util.ArrayList ;
+import java.util.Collection ;
+import java.util.Properties ;
import gnu.getopt.Getopt;
import java.util.regex.*;
@@ -28,8 +34,8 @@ class ProxyMaster {
private ServerSocket serviceSocket;
private static boolean debug=false;
private boolean doRun=true; // stops running when set to false
- private Vector<SubReader> proxyClients = new Vector<SubReader>();
- private Hashtable<String,SubReader> ghostFathers = new Hashtable<String,SubReader>(); // key: ghostId value: SubReader
+ private Collection<SubReader> proxyClients = new ArrayList<SubReader>();
+ private Map<String,SubReader> ghostFathers = new HashMap<String,SubReader>(); // key: ghostId value: SubReader
private static int serial=0;
public static final int DEFAULT_SERVICE_PORT = 3456 ;
@@ -108,7 +114,7 @@ class ProxyMaster {
String busDomain=null; // I will know it from the Hello message
SubReader(Socket socket) throws IOException {
- proxyClients.addElement(this);
+ proxyClients.add(this);
hostname = socket.getInetAddress().getHostName();
in=new BufferedReader(new InputStreamReader(socket.getInputStream()));
out=new PrintWriter(new OutputStreamWriter(socket.getOutputStream()));
@@ -136,7 +142,7 @@ class ProxyMaster {
}
traceDebug("Subreader Thread stopped");
System.out.println("ProxyClient on "+hostname+", bus "+busDomain+" disconnected");
- proxyClients.removeElement(this);
+ proxyClients.remove(this);
}
@@ -169,10 +175,8 @@ class ProxyMaster {
sr.send(msg);
} else if ((m=fwdPuppet.matcher(msg)).matches()) {
System.out.println("PM forwarding ["+msg+"] to all other PCs");
- for (Enumeration<SubReader>e=proxyClients.elements();e.hasMoreElements();) {
- SubReader sr = e.nextElement();
+ for (SubReader sr: proxyClients)
if (sr!=SubReader.this) sr.send(msg);
- }
} else {
System.out.println("error unknown message "+msg);
}