From 0dfbb137e513ad0f1773d5d07fd0d7523b51f4ce Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Thu, 3 Jun 2004 09:02:47 +0000 Subject: [PATCH] Added a mechanism for being informed when the connection manager fails to bind to its socket. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3014 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../server/net/ConnectionManager.java | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/java/com/threerings/presents/server/net/ConnectionManager.java b/src/java/com/threerings/presents/server/net/ConnectionManager.java index 8c9f7c6a5..49349d524 100644 --- a/src/java/com/threerings/presents/server/net/ConnectionManager.java +++ b/src/java/com/threerings/presents/server/net/ConnectionManager.java @@ -1,5 +1,5 @@ // -// $Id: ConnectionManager.java,v 1.38 2004/02/25 14:45:16 mdb Exp $ +// $Id: ConnectionManager.java,v 1.39 2004/06/03 09:02:47 mdb Exp $ package com.threerings.presents.server.net; @@ -57,6 +57,19 @@ public class ConnectionManager extends LoopingThread PresentsServer.registerReporter(this); } + /** + * Configures the connection manager with an entity that will be + * informed of the success or failure of the connection manager + * initialization process. Note: the callback methods will be + * called on the connection manager thread, so be careful not to do + * anything on those methods that will conflict with activities on the + * dobjmgr thread, etc. + */ + public void setStartupListener (ResultListener rl) + { + _startlist = rl; + } + /** * Specifies the authenticator that should be used by the connection * manager to authenticate logon requests. @@ -205,11 +218,21 @@ public class ConnectionManager extends LoopingThread } catch (IOException ioe) { Log.warning("Failure listening to socket on port '" +_port + "'."); Log.logStackTrace(ioe); + + // notify our startup listener, if we have one + if (_startlist != null) { + _startlist.requestFailed(ioe); + } return; } // we'll use this for sending messages to clients _framer = new FramingOutputStream(); + + // notify our startup listener, if we have one + if (_startlist != null) { + _startlist.requestCompleted(null); + } } /** @@ -656,6 +679,7 @@ public class ConnectionManager extends LoopingThread protected Authenticator _author; protected Selector _selector; protected ServerSocketChannel _listener; + protected ResultListener _startlist; /** Maps selection keys to network event handlers. */ protected HashMap _handlers = new HashMap();