The conmgr now gets its listening port number from the config file.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@201 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2001-08-08 23:56:20 +00:00
parent aa9799e8c6
commit b2d0ddee27
3 changed files with 21 additions and 12 deletions
+4 -1
View File
@@ -1,8 +1,11 @@
# #
# $Id: server.properties,v 1.2 2001/07/23 20:42:51 mdb Exp $ # $Id: server.properties,v 1.3 2001/08/08 23:56:20 mdb Exp $
# #
# Configuration for the Cher server # Configuration for the Cher server
# These invocation service providers will be registered with the # These invocation service providers will be registered with the
# invocation manager during the server init process # invocation manager during the server init process
providers = providers =
# The port on which the connection manager listens for clients.
conmgr_port = 4007
@@ -1,5 +1,5 @@
// //
// $Id: PresentsServer.java,v 1.11 2001/08/08 23:48:51 mdb Exp $ // $Id: PresentsServer.java,v 1.12 2001/08/08 23:56:20 mdb Exp $
package com.threerings.cocktail.cher.server; package com.threerings.cocktail.cher.server;
@@ -61,7 +61,7 @@ public class CherServer
// create our authentication manager // create our authentication manager
authmgr = new AuthManager(new DummyAuthenticator()); authmgr = new AuthManager(new DummyAuthenticator());
// create our connection manager // create our connection manager
conmgr = new ConnectionManager(authmgr); conmgr = new ConnectionManager(config, authmgr);
// create our client manager // create our client manager
clmgr = new ClientManager(conmgr); clmgr = new ClientManager(conmgr);
// create our distributed object manager // create our distributed object manager
@@ -1,22 +1,21 @@
// //
// $Id: ConnectionManager.java,v 1.8 2001/08/07 20:38:58 mdb Exp $ // $Id: ConnectionManager.java,v 1.9 2001/08/08 23:56:20 mdb Exp $
package com.threerings.cocktail.cher.server.net; package com.threerings.cocktail.cher.server.net;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import ninja2.core.io_core.nbio.*;
import com.samskivert.util.LoopingThread; import ninja2.core.io_core.nbio.*;
import com.samskivert.util.Tuple; import com.samskivert.util.*;
import com.samskivert.util.Queue;
import com.threerings.cocktail.cher.Log; import com.threerings.cocktail.cher.Log;
import com.threerings.cocktail.cher.io.FramingOutputStream; import com.threerings.cocktail.cher.io.FramingOutputStream;
import com.threerings.cocktail.cher.io.TypedObjectFactory; import com.threerings.cocktail.cher.io.TypedObjectFactory;
import com.threerings.cocktail.cher.net.Credentials; import com.threerings.cocktail.cher.net.Credentials;
import com.threerings.cocktail.cher.net.DownstreamMessage; import com.threerings.cocktail.cher.net.DownstreamMessage;
import com.threerings.cocktail.cher.server.CherServer;
/** /**
* The connection manager manages the socket on which connections are * The connection manager manages the socket on which connections are
@@ -31,13 +30,15 @@ public class ConnectionManager extends LoopingThread
* Constructs and initialized a connection manager (binding the socket * Constructs and initialized a connection manager (binding the socket
* on which it will listen for client connections). * on which it will listen for client connections).
* *
* @param config A config object from which the connection manager
* will fetch its configuration parameters.
* @param authmgr The authentication manager to use when * @param authmgr The authentication manager to use when
* authenticating client connections. * authenticating client connections.
*/ */
public ConnectionManager (AuthManager authmgr) public ConnectionManager (Config config, AuthManager authmgr)
throws IOException throws IOException
{ {
int port = DEFAULT_CM_PORT; _port = config.getValue(CM_PORT_KEY, DEFAULT_CM_PORT);
// keep a handle on our authentication manager // keep a handle on our authentication manager
_authmgr = authmgr; _authmgr = authmgr;
@@ -48,7 +49,7 @@ public class ConnectionManager extends LoopingThread
_selset = new SelectSet(); _selset = new SelectSet();
// create our listening socket and add it to the select set // create our listening socket and add it to the select set
_listener = new NonblockingServerSocket(port); _listener = new NonblockingServerSocket(_port);
_litem = new SelectItem(_listener, Selectable.ACCEPT_READY); _litem = new SelectItem(_listener, Selectable.ACCEPT_READY);
// when an ACCEPT_READY event happens, we do this: // when an ACCEPT_READY event happens, we do this:
_litem.obj = new NetEventHandler() { _litem.obj = new NetEventHandler() {
@@ -128,7 +129,7 @@ public class ConnectionManager extends LoopingThread
protected void willStart () protected void willStart ()
{ {
Log.info("Connection Manager thread running."); Log.info("Connection Manager listening [port=" + _port + "].");
} }
/** /**
@@ -294,6 +295,7 @@ public class ConnectionManager extends LoopingThread
_authq.append(conn); _authq.append(conn);
} }
protected int _port;
protected AuthManager _authmgr; protected AuthManager _authmgr;
protected SelectSet _selset; protected SelectSet _selset;
@@ -308,6 +310,10 @@ public class ConnectionManager extends LoopingThread
protected ArrayList _observers = new ArrayList(); protected ArrayList _observers = new ArrayList();
/** The config key for our listening port. */
protected static final String CM_PORT_KEY =
CherServer.CONFIG_KEY + ".conmgr_port";
/** The default port on which we listen for connections. */ /** The default port on which we listen for connections. */
protected static final int DEFAULT_CM_PORT = 4007; protected static final int DEFAULT_CM_PORT = 4007;