Exemple #1
0
        public static bool RemoveHandler(string name, CommandProcessorCallback handler)
        {
            string cmd = name.ToUpperInvariant();

            lock (CommandHandlers)
            {
                if (!CommandHandlers.ContainsKey(cmd) || CommandHandlers[cmd] != handler)
                {
                    return(false);
                }

                CommandHandlers.Remove(cmd);
                return(true);
            }
        }
Exemple #2
0
        public static bool RegisterHandler(string name, CommandProcessorCallback handler)
        {
            string cmd = name.ToUpperInvariant();

            lock (CommandHandlers)
            {
                if (CommandHandlers.ContainsKey(cmd))
                {
                    return(false);
                }

                CommandHandlers.Add(cmd, handler);
                return(true);
            }
        }
Exemple #3
0
        internal static bool CallHandler(string name, string body, ServerPlayer caller)
        {
            string cmd = name.ToUpperInvariant();

            CommandProcessorCallback callback = null;

            lock (CommandHandlers)
            {
                if (CommandHandlers.ContainsKey(cmd))
                {
                    callback = CommandHandlers[cmd];
                }
            }

            if (callback == null)
            {
                return(false);
            }

            callback(cmd, body, caller);
            return(true);
        }