Пример #1
0
        private readonly TcpListener _tcp; // Underlying windows socket

        public Server(Config config, HostedGame game, int broadcastPort)
        {
            Context = new GameContext(game, config);

            Context.State.Players.PlayerDisconnected     += Players_PlayerDisconnected;
            Context.State.Players.AllPlayersDisconnected += Players_AllPlayersDisconnected;

            Log.InfoFormat("Creating server {0}", Context.Game.HostAddress);

            _tcp         = new TcpListener(IPAddress.Any, Context.Game.Port);
            _broadcaster = new GameBroadcaster(Context.Game, broadcastPort);
        }
Пример #2
0
 // Creates and starts a new server
 public Server(State state, int broadcastPort)
 {
     State = state;
     Log.InfoFormat("Creating server {0}", State.Game.HostAddress);
     _tcp = new TcpListener(IPAddress.Any, State.Game.Port);
     _connectionChecker = new Thread(CheckConnections);
     _connectionChecker.Start();
     _disconnectedPlayerTimer = new Timer(CheckDisconnectedPlayers, null, 1000, 1500);
     _broadcaster             = new GameBroadcaster(State, broadcastPort);
     _pingTimer = new Timer(PingPlayers, null, 5000, 2000);
     Start();
 }
Пример #3
0
 // Creates and starts a new server
 public Server(IGameStateEngine stateEngine, int broadcastPort)
 {
     State.Instance.Engine = stateEngine;
     Log.InfoFormat("Creating server {0}", stateEngine.Game.HostUri);
     _tcp = new TcpListener(IPAddress.Any, stateEngine.Game.HostUri.Port);
     State.Instance.Handler = new Handler();
     _connectionChecker     = new Thread(CheckConnections);
     _connectionChecker.Start();
     _disconnectedPlayerTimer = new Timer(CheckDisconnectedPlayers, null, 1000, 1500);
     _broadcaster             = new GameBroadcaster(broadcastPort);
     _pingTimer = new Timer(PingPlayers, null, 5000, 2000);
     Start();
 }
Пример #4
0
 // Creates and starts a new server
 public Server(IGameStateEngine stateEngine, int broadcastPort)
 {
     State.Instance.Engine = stateEngine;
     Log.InfoFormat("Creating server {0}", stateEngine.Game.HostUri);
     _tcp = new TcpListener(IPAddress.Any, stateEngine.Game.HostUri.Port);
     State.Instance.Handler = new Handler();
     _connectionChecker = new Thread(CheckConnections);
     _connectionChecker.Start();
     _disconnectedPlayerTimer = new Timer(CheckDisconnectedPlayers, null, 1000, 1500);
     _broadcaster = new GameBroadcaster(broadcastPort);
     _pingTimer = new Timer(PingPlayers, null, 5000, 2000);
     Start();
 }