static void Main(string[] args) { // Select the map int selectedMap = 0; string[] mapFiles = Directory.GetFiles(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "/../../../../Maps"); ConsoleKey key; do { Console.Clear(); for (int i = 0; i < mapFiles.Length; i++) { Console.WriteLine("[{0}] {1}", i == selectedMap ? "X" : " ", Path.GetFileNameWithoutExtension(mapFiles[i])); } key = Console.ReadKey().Key; if (key == ConsoleKey.UpArrow && selectedMap > 0) { selectedMap--; } else if (key == ConsoleKey.DownArrow && selectedMap < mapFiles.Length) { selectedMap++; } }while (key != ConsoleKey.Enter); // Load the map var map = new TileMap(); map.LoadMap(mapFiles[selectedMap]); Room = new GameRoom(map); Console.WriteLine("MAP LOADED"); Timer.Start(); server = new WebSocketServer(IPAddress.Any, 1337); server.AddWebSocketService <GameService>("/"); server.Start(); Console.ReadKey(true); server.Stop(); Console.WriteLine("SERVER STOPPED"); }
static void Main(string[] args) { WebSocketServer appServer = new WebSocketServer(); string ip = args[0]; int port = int.Parse(args[1]); if (!appServer.Setup(ip, port)) { Console.WriteLine("Failed to setup!"); return; } appServer.NewSessionConnected += appServer_NewSessionConnected; appServer.NewDataReceived += appServer_NewDataReceived; appServer.SessionClosed += appServer_SessionClosed; //Try to start the appServer if (!appServer.Start()) { Console.WriteLine("Failed to start!"); return; } Console.WriteLine("Press Q to Stop Server"); while (Console.ReadKey().KeyChar != 'q') { continue; } appServer.Stop(); Console.WriteLine("The Server was Stopped!"); }
public void Stop() { webSocketServer.Stop(); }
static void Main(string[] args) { // INit DB // Utility.LaunchDB(); LoLClient lol = new LoLClient(); lol.GetSummonerIdByName("Hades Underworld"); //lol.GetSummonerMatchesById(); lol.GetSummonerRankingById(); lol.GetSummonerGamesById(); LoLGTContext context = new LoLGTContext(); // context. //context.Matches.Add(lol.Matches); context.StatsRanking.Add(lol.Ranking); context.SummonerGames.Add(lol.SummonerGames); context.SaveChanges(); DateTime timeAtSendToClients = new DateTime(); DateTime timeNow = new DateTime(); // ↓ Connect to ipaddress:4649/SendData WebSocketServer wssv = new WebSocketServer(System.Net.IPAddress.Any, 4649); #if DEBUG wssv.Log.Level = LogLevel.Trace; #endif wssv.KeepClean = true; wssv.WaitTime = TimeSpan.FromSeconds(120); wssv.ReuseAddress = false; // ↓ Implement Server activies in SendData.cs wssv.AddWebSocketService <SendData>("/SendData"); // LoLClient lol = new LoLClient(); Console.WriteLine(); wssv.Start(); timeAtSendToClients = DateTime.Now; string input = ""; while (input != "stop") { //timeNow = DateTime.Now; //if (timeNow == timeAtSendToClients+TimeSpan.FromMinutes(5)) //{ // // ↓ Tony add the data to send to the clients in SendData // string dataToBroadcast = ""; // wssv.WebSocketServices["/SendData"].Sessions.Broadcast(dataToBroadcast); //} //if (input.Take(5).ToString().ToLower() == "send ") //{ // string dataToBroadcast = input.Skip(5).ToString(); // wssv.WebSocketServices["/SendData"].Sessions.Broadcast(dataToBroadcast); //} input = ""; try { input = ReaderForLoops.ReadLine(150000); } catch (TimeoutException) { //Console.WriteLine("Next loop init"); } } wssv.Stop(); }
public void EndServer() { wss.Stop(); }
public static void Stop() { ws.Stop(); Console.WriteLine("Server stopped"); }