Esempio n. 1
0
        public void Stop()
        {
            if (Client != null)
            {
                Client.Stop();
                Client = null;
            }

            if (Server != null)
            {
                Server.Stop();
                Server = null;
                GhostNetWatchdog.StopWatchdog();
            }
        }
Esempio n. 2
0
        public void Start(bool server = false, bool client = false)
        {
            Stop();

            if (Settings.IsHost || server)
            {
                Server = new GhostNetServer(Celeste.Instance);
                if (!_StartHeadless)
                {
                    Celeste.Instance.Components.Add(Server);
                }
                Server.OPs.Add(0);
                Server.Start();
                GhostNetWatchdog.InitializeWatchdog();
            }

            if (!Settings.IsHost && server && !client)
            {
                return;
            }

            try {
                Client = new GhostNetClient(Celeste.Instance);
                if (!_StartHeadless)
                {
                    Celeste.Instance.Components.Add(Client);
                }
                Client.Start();
            } catch (Exception e) {
                Logger.Log(LogLevel.Warn, "ghostnet", "Failed starting client");
                Logger.LogDetailed(e);
                if (Settings.EnabledEntry != null)
                {
                    Settings.EnabledEntry.LeftPressed();
                }
                Stop();
            }
        }