Пример #1
0
 private void SendCmdToAllClient(CmdTypes cmdType, string msg = "")
 {
     foreach (var key in dicMessage.Keys)
     {
         SendCmdToClient(key, cmdType, msg);
     }
 }
Пример #2
0
 private static bool ExistType(Type type, int netCommand)
 {
     if (!CmdTypes.TryGetValue(netCommand, out HashSet <Type> types))
     {
         return(false);
     }
     return(types.Contains(type));
 }
Пример #3
0
 public void SendCmdToClient(int recognizeId, CmdTypes cmdType, [System.Diagnostics.CodeAnalysis.NotNull] string msg)
 {
     if (dicMessage.ContainsKey(recognizeId))
     {
         dicMessage[recognizeId].Enqueue(new CallbackResponse()
         {
             CmdType = cmdType, Message = msg
         });
     }
 }
Пример #4
0
        private Queue <SipperCommand> resultQueue = null;      // Queue that we get added to when execution
                                                               // of this command is completed.


        public SipperCommand(CmdTypes _cmd,
                             Queue <SipperCommand> _resultQueue,
                             CircularBuffer _sipperBuff,
                             StreamWriter _logFile
                             )
        {
            cmd         = _cmd;
            sipperBuff  = _sipperBuff;
            resultQueue = _resultQueue;
            logFile     = _logFile;
        }
Пример #5
0
        public Entry(CmdTypes cmdType, string keys, int period, MouseBtns btn, bool repeat, string seperator)
        {
            Id = Counter;
            Counter++;
            this.CmdType = cmdType;
            this.Keys    = keys;

            this.MouseBtn  = btn;
            this.Repeat    = repeat;
            this.Seperator = seperator;
        }
Пример #6
0
        public static InlineKeyboardMarkup GetByCmnd(CmdTypes command)
        {
            switch (command)
            {
            case CmdTypes.Cart:
                return(OrderKeyBoard());

            case CmdTypes.ArrivingTime:
                return(TimeKeyBoard());

            default:
                throw new Exception("Unknown command");
            }
        }
Пример #7
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            CmdTypes t = (CmdTypes)value;
            string   s;

            switch (t)
            {
            default:
                s = "Keys";
                break;

            case CmdTypes.MouseClick:
                s = "Click";
                break;

            case CmdTypes.StringList:
                s = "S-List";
                break;
            }
            return(s);
        }
Пример #8
0
        /// <summary>
        /// Method to prompt the user for input if no command-line arguments are provided.
        /// </summary>
        private static void StartPrompt()
        {
            m_LiveConsoleMode = true;     // Console window must be open, so this should be true

            ConsoleHelpers.PrintBanner(); // print a cool banner to greet our users

            //-- User input control logic --
            exitPrompt = false;
            do
            {
                Selection = ConsoleHelpers.ReadEnum <CmdTypes>("Select an Action: "); // use console helper to prompt user
                switch (Selection)
                {
                case CmdTypes.LoadProcessQueue:
                    LoadProcessQueue();
                    break;

                case CmdTypes.PrintProcessQueue:
                    PrintProcessQueue();
                    break;

                case CmdTypes.StartProcessQueue:
                    StartNextInProcessQueue();
                    break;

                case CmdTypes.Quit:
                    exitPrompt = true;
                    break;

                default:
                    break;
                }
            }while (Selection != CmdTypes.Quit && exitPrompt == false); // Keep prompting user until they make a decision.

            EndPrompt(true);                                            // end console session
        }
Пример #9
0
        private static void LoadSubscriber()
        {
            var handlerTypes = ObjectTypeStorage.GetTypes <ISubscriber>();

            foreach (var type in handlerTypes)
            {
                var attributes = type.GetCustomAttributes <NetCommandAttribute>();
                if (type.IsAbstract)
                {
                    continue;
                }

                if (attributes == null || !attributes.Any())
                {
                    throw new Exception($"类型:{type}必须有SubscriberCMDAttribute特性器指定订阅消息类型.");
                }

                var cmds       = attributes.Select(a => a.MessageCmds).SelectMany(c => c).Distinct().ToList();
                var subscriber = (ISubscriber)Activator.CreateInstance(type);

                foreach (var cmd in cmds)
                {
                    //校验订阅的NetCommand是否相同,相同抛出一个异常。
                    Validate(subscriber, cmd);

                    if (!Subscribers.TryGetValue(cmd, out Dictionary <Type, ISubscriber> subscribers))
                    {
                        subscribers      = new Dictionary <Type, ISubscriber>();
                        Subscribers[cmd] = subscribers;
                    }

                    if (subscriber.MessageType.BaseType == typeof(Enum))
                    {
                        subscribers.Add(typeof(int), subscriber);
                    }
                    else
                    {
                        subscribers.Add(subscriber.MessageType, subscriber);
                    }

                    if (subscriber.MessageType == null)
                    {
                        continue;
                    }

                    if (!CmdTypes.TryGetValue(cmd, out HashSet <Type> types))
                    {
                        types         = new HashSet <Type>();
                        CmdTypes[cmd] = types;
                    }
                    types.Add(subscriber.MessageType);

                    if (!TypeCmds.TryGetValue(subscriber.MessageType, out HashSet <int> msgCmds))
                    {
                        msgCmds = new HashSet <int>();
                        TypeCmds[subscriber.MessageType] = msgCmds;
                    }
                    msgCmds.Add(cmd);
                }
            }
        }