From e8b5d41fb8b333b5672ca64e80d7c2f2262a6b92 Mon Sep 17 00:00:00 2001 From: Mike Thomas Date: Wed, 5 Mar 2008 19:09:36 +0000 Subject: [PATCH] Split out the way we handle the preferred port so we can override that. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4958 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../presents/client/ClientCommunicator.java | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/java/com/threerings/presents/client/ClientCommunicator.java b/src/java/com/threerings/presents/client/ClientCommunicator.java index 605fbf774..35a59f815 100644 --- a/src/java/com/threerings/presents/client/ClientCommunicator.java +++ b/src/java/com/threerings/presents/client/ClientCommunicator.java @@ -49,6 +49,20 @@ public class ClientCommunicator extends BlockingCommunicator super(client); } + /** + * Sets our preferred connection port via our preferences mechanism. + */ + protected void setPrefPort (String key, int port) { + PresentsPrefs.config.setValue(key, port); + } + + /** + * Gets our preferred connection port via our preferences mechanism. + */ + protected int getPrefPort (String key, int defaultPort) { + return PresentsPrefs.config.getValue(key, defaultPort); + } + @Override // from BlockingCommunicator protected void openChannel (InetAddress host) throws IOException @@ -57,7 +71,7 @@ public class ClientCommunicator extends BlockingCommunicator // determine our preferred port String pportKey = _client.getHostname() + ".preferred_port"; int[] ports = _client.getPorts(); - int pport = PresentsPrefs.config.getValue(pportKey, ports[0]); + int pport = getPrefPort(pportKey, ports[0]); int ppidx = Math.max(0, IntListUtil.indexOf(ports, pport)); // try connecting on each of the ports in succession @@ -131,12 +145,12 @@ public class ClientCommunicator extends BlockingCommunicator public void expired () { if (clearPPI(false)) { - PresentsPrefs.config.setValue(_key, _thisPort); + setPrefPort(_key, _thisPort); } } public void failed () { - PresentsPrefs.config.setValue(_key, _nextPort); + setPrefPort(_key, _nextPort); } protected String _key;