public Server(ServerType type) { string connectionId; switch (type) { case ServerType.Socket: connectionId = SOCKET_ID; break; case ServerType.WebSocket: connectionId = WEBSOCKET_ID; break; default: connectionId = SOCKET_ID; } try { config = new sc.ServerConfig("config" + FileUtils.FILE_SEPARATOR + "server.xml"); addSocket(connectionId, new ServerSocket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)); addEndpoint(connectionId, new IPEndPoint(IPAddress.Any, int.TryParse(config.get("socket.port")))); // clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); // setServerSocket(new ServerSocket(int.TryParse(config.get("port")))); serverThread = new Thread(new ThreadStart(this.run)); //@todo rf to parent cl thread } catch (Exception e) { Console.Out.WriteLine("failed listening on port: " + config.get("port")); //add websocket port, nested config, islands System.exit(1); } addDefaultModules(); serverThread.start(); }
public static void setConfig(sc.ServerConfig config) { Server.config = config; }