From 8dd647282496bede31a6fa54c83bb84074dea621 Mon Sep 17 00:00:00 2001 From: Jamie Doornbos Date: Tue, 19 May 2009 18:05:07 +0000 Subject: [PATCH] Allow client code to detect whether or not the client is connected, since isLoggedOn returns true during the dispatch of CLIENT_DID_LOGOFF. This will allow msoy to prevent the display of room change popups when the client is disconnected. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5790 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- src/as/com/threerings/presents/client/Client.as | 9 +++++++++ src/as/com/threerings/presents/client/Communicator.as | 10 ++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/as/com/threerings/presents/client/Client.as b/src/as/com/threerings/presents/client/Client.as index c1dd2d79e..29b1c4ebb 100644 --- a/src/as/com/threerings/presents/client/Client.as +++ b/src/as/com/threerings/presents/client/Client.as @@ -234,6 +234,15 @@ public class Client extends EventDispatcher return (_clobj != null); } + /** + * Detects if the client is currently connected to the server. This can sometimes return false + * even though isLoggedOn returns true. + */ + public function isConnected () :Boolean + { + return _comm != null && _comm.isConnected(); + } + /** * Requests that this client connect and logon to the server with which it was previously * configured. diff --git a/src/as/com/threerings/presents/client/Communicator.as b/src/as/com/threerings/presents/client/Communicator.as index 4e07cd52a..3c4280cd7 100644 --- a/src/as/com/threerings/presents/client/Communicator.as +++ b/src/as/com/threerings/presents/client/Communicator.as @@ -85,6 +85,16 @@ public class Communicator } } + /** + * Detects if the communicator currently has an open channel to the server. This is guaranteed + * to return false while the logoff event is being dispatched. It also returns true during + * authentication, but prior to the client appearing to be logged on. + */ + public function isConnected () :Boolean + { + return _writer != null; + } + /** * Attempts to logon on using the port at the specified index. */