Exemplo n.º 1
0
 /// <summary>
 /// Turns this game server into a standalone game instance and disposes of
 /// any connections to game clients.
 /// </summary>
 public void StopServer()
 {
     Log.Write("Stopping game server");
     MessageHandlers.Clear();
     UnregisterServerFromManagementServer();
     _connectionAttemptListener.StopListening();
     _connectionAttemptListener = null;
     var shutdownNotice = new ConnectionClosingMessage { Info = "server shut down" };
     foreach (var conn in GameClientConnections) conn.Send(shutdownNotice);
     DisposeGameClientConnections();
     FlushUnhandledUDPMessages();
 }
Exemplo n.º 2
0
 /// <summary>
 /// Turns this game instance into a game server to whom other game instances
 /// can connect as game clients.
 /// </summary>
 /// <param name="connectionHandler">Handler of connection result.</param>
 public void StartServer(Action<Result<Connection>> connectionHandler)
 {
     Log.Write("Starting game server");
     _startServerConnectionHandler = connectionHandler;
     _connectionAttemptListener = new ConnectionAttemptListener(_game);
     _connectionAttemptListener.StartListening(Game.Settings.Net.GameServerPort, UDPSocket.PrivateLocalEndPoint.Port);
     RegisterServerToManagementServer();
 }