Ejemplo 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");
             */
        }
Ejemplo n.º 2
0
        public static bool Init_Action()
        {
            CMD_TREE.MappingAction("HELP", HELP);

            CMD_TREE.MappingAction("CITY/LIST", EMPTY);
            CMD_TREE.MappingAction("CITY/INFO", EMPTY);

            CMD_TREE.MappingAction("OFFICER/LIST", EMPTY);
            CMD_TREE.MappingAction("OFFICER/INFO", EMPTY);

            CMD_TREE.MappingAction("GAME/VERSION", EMPTY);
            CMD_TREE.MappingAction("GAME/QUIT", GAME_QUIT);
            CMD_TREE.MappingAction("GAME/TERMINATE", GAME_TERMINATE);
            return(true);
        }
Ejemplo n.º 3
0
        public static bool InitAll()
        {
            zlog.debug("Begin Init TERMINAL module");

            CMD_TREE.Init_HashCommandTree();
            CMD_ACTION.Init_Action();
            CMD_TREE.Show_HashCommandTree();

            zlog.debug("\tStart tcpTerminal");
            (new Thread(() => {
                tcpTerminal = new TcpServiceLine();
                tcpTerminal.OnClientDisconnected += new ClientDisconnectedEvent(tcpTerminal_OnClientDisconnected);
                tcpTerminal.OnClientConnectedFail += new ClientConnectedFailEvent(tcpTerminal_OnClientConnectedFail);
                tcpTerminal.OnClientConnectedSuccess += new ClientConnectedSuccessEvent(tcpTerminal_OnClientConnectedSuccess);
                tcpTerminal.OnLineArrival += new LineArrivalEvent(tcpTerminal_OnLineArrival);
                tcpTerminal.nameServer = "TERMINAL";
                isTcpStartSuccess = tcpTerminal.start(
                    RUN.Config[KW.TerminalListenIp],
                    RUN.Config.get_int(KW.TerminalListenPort),
                    RUN.Config.get_int(KW.TerminalMaxWorker)
                    );
                trickTcpStart.Set();
                if (!isTcpStartSuccess)
                {
                    return;
                }
                // begin monitoring global Signal
                while (!that.isQuit)
                {
                    Thread.Sleep(1000);
                }
                // global signal is Fire, then stop SERVER
                tcpTerminal.stop();
            })).Start();
            trickTcpStart.WaitOne();
            if (isTcpStartSuccess)
            {
                zlog.debug("\t* Success Init Terminatel Module");
                return(true);
            }
            else
            {
                zlog.debug("\t! FAIL Init Terminatel Module");
                return(true);
            }
        }