Advertisement
Guest User

GameServer.cs

a guest
Jul 1st, 2016
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.28 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using Past.Utils;
  7. using Past.Network.Login;
  8.  
  9. namespace Past.Network.Game
  10. {
  11.     public class GameServer
  12.     {
  13.         private static Server Game { get; set; }
  14.         public static List<GameClient> Clients = new List<GameClient>();
  15.  
  16.         public static void Start()
  17.         {
  18.             Game = new Server("127.0.0.1", 5555);
  19.             Game.OnServerStarted += Game_OnServerStarted;
  20.             Game.OnServerAcceptedSocket += Game_OnServerAcceptedSocket;
  21.             Game.OnServerFailedToStart += Game_OnServerFailedToStart;
  22.             Game.Start();
  23.  
  24.         }
  25.  
  26.         private static void Game_OnServerFailedToStart(Exception ex)
  27.         {
  28.             ConsoleUtils.Write(ConsoleUtils.type.ERROR, ex.ToString());
  29.         }
  30.  
  31.         private static void Game_OnServerStarted()
  32.         {
  33.             ConsoleUtils.Write(ConsoleUtils.type.INFO, "GameServer waiting for new connexion ...");
  34.         }
  35.  
  36.         private static void Game_OnServerAcceptedSocket(Client socket)
  37.         {
  38.             ConsoleUtils.Write(ConsoleUtils.type.INFO, "New client trying to connect to GameServer ...");
  39.             Clients.Add(new GameClient(socket));
  40.         }
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement