Esempio n. 1
0
        static void ProcessCommand(string sLine, ClientTcp clientRec)
        {
            List <string>     lSubCmd    = null;
            List <string>     lParam     = null;
            Action <Object[]> actionProc = null;

            if (CMD_TREE.TranslateCommand(sLine, ref lSubCmd, ref lParam, ref actionProc))
            {
                if (actionProc == null)
                {
                    zlog.info("Found Command & " + lParam.Count.ToString() + " Param, BUT NO ACTION  Mapping");
                }
                else
                {
                    zlog.info(
                        "Found Action Object, then Call-> " +
                        actionProc.Method.Name +
                        "(" +
                        lParam.Count.ToString() + "," + "#" +
                        clientRec.id.ToString() +
                        ")"
                        );
                    actionProc.Invoke(new object[] { lParam, clientRec });
                }
            }
            else
            {
                if (lSubCmd == null)
                {
                    zlog.error("Unknow or Invalid Command");
                }
                else if (lSubCmd.Count > 0)
                {
                    zlog.debug("Request next sub command: " + string.Join(",", lSubCmd.ToArray()));
                    clientRec.write_line("Sub-command: [" + string.Join("] [", lSubCmd.ToArray()) + "]");
                }
                else
                {
                    zlog.debug("No Next Sub Command");
                }
            }

            /*
             * if (sLine.Trim().Length < 1) { clientRec.write_line(that.Version); return; }
             * CMD cmd = new CMD(sLine);
             * if (!cmd.valid) { clientRec.write_line("Invalid Command format"); return; }
             * zlog.debug("CMD[" + cmd.name + "]");
             * foreach (string s in cmd.param)
             * {
             *      zlog.debug("Param = " + s);
             * }
             * clientRec.write_line("OK");
             */
        }