using System; using System.Net; using websocketserver.Library; namespace websocketserver { class Program { static void Main(string[] args) { // WebSocket server port int port = 8080; if (args.Length > 0) { port = int.Parse(args[0]); } Console.WriteLine($"WebSocket server port: {port}"); var server = new ChatServer(IPAddress.Any, port); Console.Write("Server starting..."); server.Start(); Console.WriteLine(" Done!"); Console.WriteLine("Commands: "); Console.WriteLine("\tquit: stops the server"); Console.WriteLine("\trestart: restarts the server"); for (;;) { string line = Console.ReadLine(); if (string.IsNullOrEmpty(line)) { continue; } if (line == "quit" || line == "exit") { break; } if (line == "restart") { //TODO: broadcast to all users a disconnect Console.Write("Server restarting..."); server.Restart(); Console.WriteLine(" Done!"); continue; } line = "(admin) " + line; Console.WriteLine(" Done!"); server.MulticastText(line); } Console.Write("Server stopping..."); server.Stop(); Console.WriteLine("Done!"); } } }