public void StartAcceptingConnections() { AcceptingConnections = true; if (LobbyID.IsLobby()) { SteamMatchmaking.SetLobbyJoinable(LobbyID, true); } }
public void StopAcceptingConnections() { AcceptingConnections = false; if (LobbyID.IsLobby()) { SteamMatchmaking.SetLobbyJoinable(LobbyID, false); } }
/// <summary> /// Disconnects this server and all of it's clients /// </summary> /// <param name="forced">Used to tell if this disconnect was intentional <c>false</c> or caused by an exception <c>true</c></param> public override void Disconnect(bool forced) { // Since we are disconnecting we need to stop the read thread Logging.BMSLog.Log("<color=cyan>SteamP2P server disconnecting...</color>"); StopAcceptingConnections(); readThreadCancel = true; lock (Players) { // Go through all of the players and disconnect them foreach (NetworkingPlayer player in Players) { if (player != Me) { Disconnect(player, forced); } } CleanupDisconnections(); int counter = 0; for (; ; counter++) { if (counter >= 10 || Players.Count == 1) { break; } Thread.Sleep(100); } // Send signals to the methods registered to the disconnect events if (!forced) { OnDisconnected(); } else { OnForcedDisconnect(); } // Stop listening for new connections Client.Close(); } if (LobbyID.IsLobby()) { SteamMatchmaking.LeaveLobby(LobbyID); } }
/// <summary> /// Disconnect this client from the server /// </summary> /// <param name="forced">Used to tell if this disconnect was intentional <c>false</c> or caused by an exception <c>true</c></param> public override void Disconnect(bool forced) { Logging.BMSLog.Log("<color=cyan>SteamP2P client disconnecting...</color>"); if (LobbyID.IsLobby()) { SteamMatchmaking.LeaveLobby(LobbyID); } if (Client == null) { return; } lock (Client) { if (forced) { CloseConnection(); } else { var frame = new ConnectionClose(Time.Timestep, false, Receivers.Server, MessageGroupIds.DISCONNECT, false); Send(frame, true); Task.Queue(CloseConnection, 1000); } // Send signals to the methods registered to the disconnect events if (forced) { // OnDisconnected(); //else OnForcedDisconnect(); } } }