From 56417cdb0abe14de6f8403543abe591fbd024869 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Fri, 28 Jan 2005 05:03:37 +0000 Subject: [PATCH] Indicate whether we rejected an attempt to logon because we're still in the throes of a previous connection. Also don't spuriously recreate our ticker because it's very possible for logon() to be called and not logoff(), logon() might fail, for example. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3321 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../threerings/presents/client/Client.java | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/java/com/threerings/presents/client/Client.java b/src/java/com/threerings/presents/client/Client.java index 52910f17e..dad06c5db 100644 --- a/src/java/com/threerings/presents/client/Client.java +++ b/src/java/com/threerings/presents/client/Client.java @@ -339,12 +339,15 @@ public class Client /** * Requests that this client connect and logon to the server with * which it was previously configured. + * + * @return false if we're already logged on, true if a logon attempt + * was initiated. */ - public synchronized void logon () + public synchronized boolean logon () { // if we have a communicator reference, we're already logged on if (_comm != null) { - return; + return false; } // otherwise create a new communicator instance and start it up. @@ -355,12 +358,16 @@ public class Client // register an interval that we'll use to keep the clock synced // and to send pings when appropriate - _tickInterval = new Interval() { - public void expired () { - tick(); - } - }; - _tickInterval.schedule(5000L, true); + if (_tickInterval == null) { + _tickInterval = new Interval() { + public void expired () { + tick(); + } + }; + _tickInterval.schedule(5000L, true); + } + + return true; } /**