public GhostNetRaceManager(GhostNetServer server)
        {
            Server = server;

            server.OnHandle     += Handle;
            server.OnDisconnect += Disconnect;

            server.Commands.Add(CommandRace = new GhostNetDCommand {
                Name = "race",
                Args = "+ [<sid> <side>] | - <index> | start | join <id> | leave | list | areas [raceid] | players [raceid]",
                Help =
                    @"Create, join, start and leave races.
Use + and - to add and remove areas from a race.
If using + outside a race, you're creating a new one.
You can chat with your fellow racers using the rc command.",
                OnRun = RunCommandRace
            });

            server.Commands.Add(CommandRaceChat = new GhostNetDCommand {
                Name = "rc",
                Args = "<message>",
                Help =
                    @"Chat with your fellow racers!",
                OnParse = GhostNetDCommand.Parsers.Everything,
                OnRun   = RunCommandRaceChat
            });
        }
Example #2
0
        public void Stop()
        {
            if (Client != null)
            {
                Client.Stop();
                Client = null;
            }

            if (Server != null)
            {
                Server.Stop();
                Server = null;
            }
        }
Example #3
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();
            }

            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");
                e.LogDetailed();
                if (Settings.EnabledEntry != null)
                {
                    Settings.EnabledEntry.LeftPressed();
                }
                Stop();
            }
        }
 public static void OnCreateServer(GhostNetServer server)
 {
     server.ModData["raceman"] = new GhostNetRaceManager(server);
 }