Example #1
0
        public void Test_sendPcbGamePatchToMaster()
        {
            //for test
            PcbGamePatch pcbGamePatch = new PcbGamePatch();

            pcbGamePatch.pcbGames = new List <PcbGame>();

            pcbGamePatch.pcbGames.Add(new PcbGame("1", "game1", "100", "10"));
            pcbGamePatch.pcbGames.Add(new PcbGame("2", "game2", "200", "20"));
            pcbGamePatch.pcbGames.Add(new PcbGame("3", "game3", "300", "30"));
            pcbGamePatch.pcbGames.Add(new PcbGame("4", "game4", "400", "40"));
            pcbGamePatch.pcbGames.Add(new PcbGame("5", "game5", "500", "50"));

            String result = PcbAgent.Instance.sendPcbGamePatchToMaster(pcbGamePatch);
        }
Example #2
0
        public string sendPcbGamePatchToMaster(PcbGamePatch pcbGamePatch)
        {
            if (pcbGamePatch == null)
            {
                return("pcbGamePatch is null!");
            }
            if (pcbGamePatch.pcbGames.Count == 0)
            {
                return("pcbGamePatch.pcbGames is empty!");
            }

            string urlPath = PcbAgent.buildUriForApiRequest(PcbAgent.REQUEST_GAME_PATCH + getLocalIPAddress());

            Console.WriteLine("[sendPcbGamePatchToMaster] pcbGamePatch result:{0}", MsgConverter.pack <PcbGamePatch>(pcbGamePatch));

            return(HttpSender.requestJson(urlPath, MsgConverter.pack <PcbGamePatch>(pcbGamePatch)));
        }
Example #3
0
        //핵심 mission들 수행 test
        public string executeMissions(bool isForce)
        {
            //10초 ~ 1분 사이에 실행됨 실행
            Random random = new Random();

            Thread.Sleep(random.Next(20, DELAY_TIME_SEC) * 1000);

            if (!isForce && checkGamePatchPass())
            {
                return("PASS");
            }

            //request Agent Command
            AgentCommand agentCmd = requestAgentCommand();

            PcbGamePatch pcbGamePatch = new PcbGamePatch();

            pcbGamePatch.pcbGames = new List <PcbGame>();
            pcbGamePatch.version  = PcbAgent.AGENT_VERSION;

            //GameCommand 처리
            foreach (GameCommand gameCmd in agentCmd.gameCommands)
            {
                PcbGame pcbGame = executeGameCommand(gameCmd);
                if (pcbGame != null)
                {
                    pcbGamePatch.pcbGames.Add(pcbGame);
                }
            }

            //gamepatch 정보 전송
            String result = sendPcbGamePatchToMaster(pcbGamePatch);

            Debug.WriteLine("[executeMissions] sendPcbGamePatchToMaster result:" + result);
            return(result);
        }
Example #4
0
        public PcbGamePatch buildPcbGamePatch()
        {
            //target game 목록 생성
            List <TargetGame> targetGames = TargetGameFactory.buildAllGames();

            //target game의 exefile들을 검색하여 위치 파악
            List <string> exeFiles = new List <string>();
            List <string> verFiles = new List <string>();

            foreach (TargetGame aGame in targetGames)
            {
                exeFiles.Add(aGame.Exefile);
                if (aGame.IsVerFileOtherPath)
                {
                    verFiles.Add(aGame.VersionFile);
                }
            }

            FileFinder    finder     = new FileFinder("*.exe", exeFiles);
            List <string> foundFiles = finder.findFilePath();

            finder = new FileFinder("*.upf", verFiles);
            List <string> foundVerFiles = finder.findFilePath();

            //            Dictionary<string, string> foundExeFileMap = TargetGameFactory.buildFoundExeFileMap(foundFiles, targetGames);
            targetGames = TargetGameFactory.matchFoundExeFileAndVerFile(foundFiles, foundVerFiles, targetGames);

            //target game 별로 version 체크
            PcbGamePatch pcbGamePatch = new PcbGamePatch();

            pcbGamePatch.pcbGames = new List <PcbGame>();

            foreach (TargetGame aGame in targetGames)
            {
                //exefile 존재 여부 체크
                string exeFilePath = aGame.ExeFilePath;
                if (exeFilePath == null)
                {
                    Console.WriteLine("[buildPcbGamePatch] exeFile is not found! gsn:{0}, exefile:{1}", aGame.Gsn, aGame.Exefile);
                    continue;
                }

                //version file 여부 체크
                if (aGame.VersionFile == null)
                {
                    //설치여부만 체크
                    pcbGamePatch.pcbGames.Add(new PcbGame(aGame.Gsn, aGame.Exefile, "N/A", VersionChecker.checkLastWriteTime(exeFilePath)));
                }
                else
                {
                    //string versionFilePath = FileFinder.findOneFilePath(gameInstallPath, aGame.VersionFile);

                    if (aGame.VerionFilePath == null)
                    {
                        continue;
                    }

                    //Console.WriteLine("[buildPcbGamePatch] versionFilePath:{0}", aGame.VerionFilePath);

                    //버전파일 체크
                    switch (aGame.VersionFileFormat)
                    {
                    case Fileformat.XML:
                        pcbGamePatch.pcbGames.Add(new PcbGame(aGame.Gsn, aGame.Exefile, VersionChecker.checkXmlFile(aGame.VerionFilePath), VersionChecker.checkLastWriteTime(exeFilePath)));
                        break;

                    case Fileformat.JSON:
                        pcbGamePatch.pcbGames.Add(new PcbGame(aGame.Gsn, aGame.Exefile, VersionChecker.checkJsonFile(aGame.VerionFilePath), VersionChecker.checkLastWriteTime(exeFilePath)));
                        break;

                    case Fileformat.BIN:
                        pcbGamePatch.pcbGames.Add(new PcbGame(aGame.Gsn, aGame.Exefile, VersionChecker.checkLastWriteTime(aGame.VerionFilePath), VersionChecker.checkLastWriteTime(exeFilePath)));
                        break;

                    default:
                        //no process
                        Console.WriteLine("[buildPcbGamePatch] not supprot version formant:{0}", aGame.VersionFileFormat);
                        break;
                    }
                }
            }

            //set agent version
            pcbGamePatch.version = PcbAgent.AGENT_VERSION;

            return(pcbGamePatch);
        }