예제 #1
0
        public Server(ServerType type)
        {
            string connectionId;

            connectionId = getConnectionId(type);

            try
            {
                config = new sc.ServerConfig("config" + su.FileUtils.getFileSeparator() + "server.xml");

                //@todo refactor to SocketInformation Factory
                addSocket(connectionId,
                          new ServerSocket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp));
                //@todo encapsulate into Factory
                addEndpoint(connectionId, new IPEndPoint(IPAddress.Any, int.Parse(config.get("socket.port"))));

                // clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                // setServerSocket(new ServerSocket(int.TryParse(config.get("port"))));

                //rf to parent cl thread (not possible - sealed)
                serverThread = new Thread(new ThreadStart(this.run));
            }
            catch (Exception e)
            {
                Console.Out.WriteLine("failed listening on port: " + config.get("port"));
                //add websocket port, nested config, islands
                Environment.Exit(1);
            }

            addDefaultModules();

            serverThread.Start();
        }
예제 #2
0
 public static void setConfig(sc.ServerConfig config)
 {
     Server.config = config;
 }