public static void Stop(string reason = "") { ListenerServer.Shutdown(string.IsNullOrEmpty(reason) ? "Server is shutting down..." : reason); Listen = false; WebSocketListener.Stop((reason == "ServerHub exception occured!" ? WebSocketSharp.CloseStatusCode.ServerError : WebSocketSharp.CloseStatusCode.Away), reason); hubClients.ForEach(x => x.KickClient(string.IsNullOrEmpty(reason) ? "Server is shutting down..." : reason)); RadioController.StopRadio(string.IsNullOrEmpty(reason) ? "Server is shutting down..." : reason); }
public static void Stop(string reason = "") { ListenerServer.Shutdown(string.IsNullOrEmpty(reason) ? "Server is shutting down..." : reason); Listen = false; WebSocketListener.Stop(); hubClients.ForEach(x => x.KickClient(string.IsNullOrEmpty(reason) ? "Server is shutting down..." : reason)); RadioController.StopRadio(string.IsNullOrEmpty(reason) ? "Server is shutting down..." : reason); }
public static void Start() { if (Settings.Instance.Server.EnableWebSocketServer) { WebSocketListener.Start(); } pingTimer = new Timer(PingTimerCallback, null, 7500, 10000); HighResolutionTimer.LoopTimer.Elapsed += HubLoop; HighResolutionTimer.LoopTimer.AfterElapsed += (sender, e) => { if (ListenerServer != null) { ListenerServer.FlushSendQueue(); } }; HighResolutionTimer.VoIPTimer.AfterElapsed += (sender, e) => { if (ListenerServer != null) { ListenerServer.FlushSendQueue(); } }; _lastTick = DateTime.Now; NetPeerConfiguration Config = new NetPeerConfiguration("BeatSaberMultiplayer") { Port = Settings.Instance.Server.Port, EnableUPnP = Settings.Instance.Server.TryUPnP, AutoFlushSendQueue = false, MaximumConnections = 512 }; Config.EnableMessageType(NetIncomingMessageType.ConnectionApproval); ListenerServer = new NetServer(Config); ListenerServer.Start(); if (Settings.Instance.Radio.EnableRadio) { RadioController.StartRadio(); } if (Settings.Instance.Server.TryUPnP) { ListenerServer.UPnP.ForwardPort(Config.Port, "Beat Saber Multiplayer ServerHub"); } }
public static void Stop(string reason = "") { ListenerServer.Shutdown(string.IsNullOrEmpty(reason) ? "Server is shutting down..." : reason); Listen = false; WebSocketListener.Stop((reason == "ServerHub exception occured!" ? WebSocketSharp.CloseStatusCode.ServerError : WebSocketSharp.CloseStatusCode.Away), reason); for (int i = 0; i < hubClients.Count; i++) { if (hubClients.Count > i) { hubClients[i].KickClient(string.IsNullOrEmpty(reason) ? "Server is shutting down..." : reason); } } RadioController.StopRadio(string.IsNullOrEmpty(reason) ? "Server is shutting down..." : reason); }