Exemplo n.º 1
0
        private static void HandleServerRequest(string value)
        {
            value = value.Trim();
            string instruction = value;
            string args        = null;

            // Check if we got parameters with the instruction
            if (value.IndexOf(' ') > -1)
            {
                instruction = value.SplitCommand()[0];
                args        = value.SplitCommand()[1];
            }

            // Is request registered?
            IServerRequest request = ServerRequestRegistry.GetHandler(instruction);

            if (request != null)
            {
                request.Run(args);
            }
            else
            {
                // Protocol request unknown, inform client
                ClientMessage.Info($"Unknown protocol value: {value}");
            }
        }
Exemplo n.º 2
0
        public MainWindow()
        {
            InitializeComponent();

            // Hook main window up to messenger
            ClientMessage.SetTarget(ChannelTextBlock);

            // Register slash commands
            SlashCommandRegistry.RegisterHandler("connect", new Commands.Slash.Connect());
            SlashCommandRegistry.RegisterHandler("disconnect", new Commands.Slash.Disconnect());
            SlashCommandRegistry.RegisterHandler("raw", new Commands.Slash.Raw());
            SlashCommandRegistry.RegisterHandler("chan", new Commands.Slash.SetChannel());
            SlashCommandRegistry.RegisterHandler("join", new Commands.Slash.Join());

            // Register server requests
            ServerRequestRegistry.RegisterHandler("NOTICE", new Commands.ServerRequest.Notice());
            ServerRequestRegistry.RegisterHandler("JOIN", new Commands.ServerRequest.Join());
            ServerRequestRegistry.RegisterHandler("PRIVMSG", new Commands.ServerRequest.PrivMsg());
        }