Beispiel #1
0
        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");
            }
        }
Beispiel #2
0
 private void OnEnable()
 {
     radioController.StartRadio();
 }