/* * Copyright (C) 1996, 1997 By Radu Sion * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by Radu Sion (radus@cs.pub.ro) * * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR `AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * (radus@cs.pub.ro, http://www.dsp.pub.ro/radu.html) * */ import RoundRobinServerThread; import ConnectServerThread; import ResourceFileReader; import ResourceHash; import PasswordServerConnectAAA; import dbg; /** * The main server side class that starts all server threads.

* Written: Radu Sion
* Version: 0.19
* Source: ServerMain.java * @see RoundRobinServerThread * @see ConnectServerThread */ class ServerMain { RoundRobinServerThread rrst; ConnectServerThread cst; PasswordServerConnectAAA pscaaa; /** * Fires up all the threads that compose the system. * @param rh Resource Hash to use */ public ServerMain(ResourceHash rh) { String pfile = rh.getString("PASSWORD_FILE"); if (PasswordServerConnectAAA.testFile(pfile)) { pscaaa = new PasswordServerConnectAAA(pfile); } else { System.err.println("Password file " + pfile + " is invalid."); return; } /** Main server thread **/ dbg.p(dbg.INFO,"MAIN: Starting RoundRobinServerThread ..."); /* 255 maxplayers, 1/2 second = mindelay */ rrst = new RoundRobinServerThread(rh); rrst.start(); dbg.p(dbg.INFO,"MAIN: Done Starting RoundRobinServerThread."); /** Connect server thread **/ dbg.p(dbg.INFO,"MAIN: Starting ConnectServerThread ..."); cst = new ConnectServerThread((int)rh.getLongValue("PORT"), rrst, pscaaa, rh.getLongValue("CST_SLEEP")); cst.start(); dbg.p(dbg.INFO,"MAIN: Done Starting ConnectServerThread."); } public static void main(String argv[]) { System.out.println(ConfigureConstants.GREETING); if (argv.length<1) { System.err.println("Usage: Main resource_file"); return; } /** reading resource file **/ ResourceHash rh = ResourceFileReader.read(argv[0]); if (rh == null) { System.err.println("Unable to read resource file " + argv[0] + "."); return; } ServerMain dummy = new ServerMain(rh); } } /*eoc*/