public static void Main(string[] args) { if (args.Length <= 0) { Console.WriteLine("Error: Must specify config file. Run JacoChatServer.exe [CONFIG.CONF]"); return; } Config = new JacoChatConfigurationReader(args[0]).Read(); if (Config.OutputMode == OutputMode.FilePath) logWriter = new StreamWriter(Config.OutputFilePath); Server.Listen(Config.HostIp, Config.Port); Server.MessageRecieved += server_OnMessageRecieved; Server.UserDisconnected += server_OnUserDisconnected; Server.UserConnected += server_OnUserConnected; }
public JacoChatConfiguration Read() { JacoChatConfiguration config = new JacoChatConfiguration(); config.OutputMode = OutputMode.StdOut; config.HostIp = "127.0.0.1"; config.Port = 1337; config.MotdPath = ""; for (int i = 0; i < contents.Length; i++) { string line = contents[i]; if (line.Trim().StartsWith("#") || line == "" || line == "\n") continue; string[] parts = line.Split(' '); switch (parts[0].ToLower()) { case "outputmode": if (parts[1].ToLower() == "stdout") config.OutputMode = OutputMode.StdOut; else { config.OutputMode = OutputMode.FilePath; config.OutputFilePath = parts[1]; } break; case "hostname": config.HostIp = parts[1]; break; case "port": config.Port = Convert.ToInt32(parts[1]); break; case "motd": config.MotdPath = parts[1]; break; case "netop": config.NetOPs.Add(parts[1], parts[2]); break; } } return config; }