Exemplo n.º 1
0
        public void ReadResult(RunnerCommand cmd, BinaryReader reader)
        {
            switch (cmd)
            {
            case RunnerCommand.Ping:
            {
                ReadPingResults(reader);
                break;
            }

            case RunnerCommand.GetUpdate:
            {
                ReadUpdateResults(reader);
                break;
            }

            case RunnerCommand.GetInstanceData:
            {
                ReadInstanceResults(reader);
                break;
            }

            default: break;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 处理ExecuteService的远程指令【runner控制】
        /// </summary>
        void MessageTransferChannel_RunnerCommandCallback(ExecuteService sender, RunnerCommand command, List <int> runners)
        {
            List <CaseRunner> caseRunnerList = CaseRunnerList;

            if (caseRunnerList == null)
            {
                return;
            }
            RunnerCommandExecute(caseRunnerList, command, runners);
        }
 public bool Read()
 {
     this._command = (RunnerCommand)this.ReadByte();
     switch (this._command)
     {
         case RunnerCommand.Log:
             this._message = this.ReadString();
             return true;
         case RunnerCommand.Exit:
             this._exitCode = (byte)this.ReadByte();
             return false;
         default:
             throw new InvalidOperationException();
     }
 }
        public RunnerClientConnection(TcpClient client)
            : base(client)
        {
            uint magic;

            magic = this.ReadUInt32();
            if (magic != MagicNumber)
                throw new IOException(String.Format(
                    "unexpected magic number: {0:X8}",
                    magic));
            this._processId = this.ReadInt32();
            this._command = RunnerCommand.None;
            this._message = null;
            this._exitCode = (-1);
        }
Exemplo n.º 5
0
        public bool Read()
        {
            this._command = (RunnerCommand)this.ReadByte();
            switch (this._command)
            {
            case RunnerCommand.Log:
                this._message = this.ReadString();
                return(true);

            case RunnerCommand.Exit:
                this._exitCode = (byte)this.ReadByte();
                return(false);

            default:
                throw new InvalidOperationException();
            }
        }
Exemplo n.º 6
0
        public RunnerClientConnection(TcpClient client)
            : base(client)
        {
            uint magic;

            magic = this.ReadUInt32();
            if (magic != MagicNumber)
            {
                throw new IOException(String.Format(
                                          "unexpected magic number: {0:X8}",
                                          magic));
            }
            this._processId = this.ReadInt32();
            this._command   = RunnerCommand.None;
            this._message   = null;
            this._exitCode  = (-1);
        }
Exemplo n.º 7
0
        public void AddCommand(RunnerCommand cmd, params object[] args)
        {
            if (IsBatching)
            {
                switch (cmd)
                {
                case RunnerCommand.Ping:
                {
                    BatchCmdCount++;
                    BatchWriter.Write((int)RunnerCommand.Ping);
                    BatchWriter.Write((uint)args[0]);        // sendID
                    BatchWriter.Write((int)args[1]);         // flags
                    break;
                }

                case RunnerCommand.GetUpdate:
                {
                    BatchCmdCount++;
                    BatchWriter.Write((int)RunnerCommand.GetUpdate);
                    BatchWriter.Write((int)args[0]);         // flags
                    break;
                }

                case RunnerCommand.GetInstanceData:
                {
                    BatchCmdCount++;
                    BatchWriter.Write((int)RunnerCommand.GetInstanceData);
                    BatchWriter.Write(AllInstances.Count);
                    for (int i = 0; i < AllInstances.Count; i++)
                    {
                        BatchWriter.Write(AllInstances[i].ID);
                    }
                    break;
                }
                }
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// 执行远程命令
        /// </summary>
        /// <param name="caseRunnerList">CaseRunner 列表</param>
        /// <param name="command">命令类型</param>
        /// <param name="Runners">受影响Runner</param>
        private void RunnerCommandExecute(List <CaseRunner> caseRunnerList, RunnerCommand command, List <int> Runners)
        {
            switch (command)
            {
            case RunnerCommand.Start:
                if (Runners != null)
                {
                    if (Runners.Count > 0)
                    {
                        foreach (int tempRunnerIndex in Runners)
                        {
                            if (caseRunnerList.Count >= tempRunnerIndex)
                            {
                                caseRunnerList[tempRunnerIndex].RunQuiet();
                            }
                            else
                            {
                                AddInfo("tempRunnerIndex error");
                            }
                        }
                    }
                }
                else
                {
                    AddInfo("Runners is null");
                }
                break;

            case RunnerCommand.Stop:
                if (Runners != null)
                {
                    if (Runners.Count > 0)
                    {
                        foreach (int tempRunnerIndex in Runners)
                        {
                            if (caseRunnerList.Count >= tempRunnerIndex)
                            {
                                caseRunnerList[tempRunnerIndex].StopQuiet();
                            }
                            else
                            {
                                AddInfo("tempRunnerIndex error");
                            }
                        }
                    }
                }
                else
                {
                    AddInfo("Runners is null");
                }
                break;

            case RunnerCommand.Pause:
                if (Runners != null)
                {
                    if (Runners.Count > 0)
                    {
                        foreach (int tempRunnerIndex in Runners)
                        {
                            if (caseRunnerList.Count >= tempRunnerIndex)
                            {
                                caseRunnerList[tempRunnerIndex].PauseQuiet();
                            }
                            else
                            {
                                AddInfo("tempRunnerIndex error");
                            }
                        }
                    }
                }
                else
                {
                    AddInfo("Runners is null");
                }
                break;

            default:
                break;
            }
        }
Exemplo n.º 9
0
        public bool Load(byte[] dat)
        {
            var reader = new BinaryReader(new MemoryStream(dat));

            RunnerCommand cmd = (RunnerCommand)reader.ReadInt32();

            if (cmd != RunnerCommand.GetGameData)
            {
                Console.WriteLine("Invalid command, expected GetGameData!");
                return(false);
            }

            if (ReadString(reader) != "_REV")
            {
                Console.WriteLine("Wrong chunk name. Expected VER_");
                return(false);
            }

            int GL_version = reader.ReadInt32();

            if (GL_version != GAMELAYOUT_VERSION)
            {
                Console.WriteLine("Unsupported GameLayout version, expected 9");
                return(false);
            }

            PlatformCode = (Platform)reader.ReadInt32();

            // And now, the fun part begins. Where we load the actual data.

            if (ReadString(reader) != "EDOC")
            {
                Console.WriteLine("Wrong chunk name. Expected CODE");
                return(false);
            }
            Read_VMCode(reader);

            if (ReadString(reader) != "_JBO")
            {
                Console.WriteLine("Wrong chunk name. Expected OBJ_");
                return(false);
            }
            Read_OBJT(reader);

            if (ReadString(reader) != "TRCS")
            {
                Console.WriteLine("Wrong chunk name. Expected SCRT");
                return(false);
            }
            Read_SCRT(reader);

            if (ReadString(reader) != "CNUF")
            {
                Console.WriteLine("Wrong chunk name. Expected FUNC");
                return(false);
            }
            Read_FUNC(reader);

            if (ReadString(reader) != "DOCC")
            {
                Console.WriteLine("Wrong chunk name. Expected CCOD");
                return(false);
            }
            Read_CreationCode(reader);

            if (ReadString(reader) != "NLMT")
            {
                Console.WriteLine("Wrong chunk name. Expected TMLN");
                return(false);
            }
            Read_TimelineCode(reader);

            return(true);
        }