Beispiel #1
0
        private void HandlePromptInput(object sender, PromptInputEvent inputEvent)
        {
            String[] args = inputEvent.SplitCommandLine().ToArray();

            if (args.Length == 0)
                return;

            if (args[0].ToLower().Equals("/connect", StringComparison.OrdinalIgnoreCase))
            {
                String host = null, callsign = null, tag = null;
                UInt16 port = 5150;

                OptionSet p = new OptionSet() {
                { "h=|host=",
                    "host of server to connect to",
                    (String v) => host = v
                    },
                { "p=|port=",
                    "port of server to connect to",
                    (UInt16 v) => port = v
                    },
                { "c=|callsign=",
                    "callsign to use",
                    (String v) => callsign = v
                    },
                { "t|tag=",
                    "tag to use",
                    (String v) => tag = v
                    },
                };

                List<String> extra;
                try
                {
                    extra = p.Parse(args);
                }
                catch (OptionException e)
                {
                    gameConsole.WriteLine(e.Message);

                    StringWriter descriptions = new StringWriter();
                    p.WriteOptionDescriptions(descriptions);
                    WriteConsoleLines(descriptions);

                    return;
                }

                if (host == null || callsign == null)
                {
                    gameConsole.WriteLine("Host and callsign are required.");

                    StringWriter descriptions = new StringWriter();
                    p.WriteOptionDescriptions(descriptions);
                    WriteConsoleLines(descriptions);

                    return;
                }

                Connect(host, port, callsign, tag, TeamType.RogueTeam);
            }
        }
Beispiel #2
0
        private void FireInputEvent(String input)
        {
            EventHandler<PromptInputEvent> handler = PromptReceivedInput;

            // prevent race condition
            if (handler != null)
            {
                // notify delegates attached to event
                PromptInputEvent e = new PromptInputEvent(input);
                handler(this, e);
            }
        }