package GPServer; /** *

Title:

*

Description:

*

Copyright: Copyright (c) 2000

*

Company:

* @author not attributable * @version 1.0 */ import java.lang.*; import java.io.*; import java.net.*; import java.util.*; public class GameServer { private Hashtable openGames = new Hashtable(); private ServerSocket ss; private Socket s; public GameServer(int port) { ServerThread.server = this; GameThread.server = this; try{ listen(port); } catch(IOException e){ e.printStackTrace(); } } public static void main(String[] args) { int port = Integer.parseInt(args[0]); GameServer gameServer1 = new GameServer(port); } private void listen(int port) throws IOException{ ss = new ServerSocket(port); while(true){ s = ss.accept(); new ServerThread(s); } } protected void addOpenGame(GameThread game,String key){ synchronized(openGames){ openGames.put(key,game); } } protected GameThread getOpenGame(String key){ GameThread game; synchronized(openGames){ game = (GameThread) openGames.get(key); } return game; } protected Enumeration getOpenGamesList(){ Enumeration list; synchronized(openGames){ list = openGames.keys(); } return list; } }