예제 #1
0
        public void CallWeb(WebSlaveParam param)
        {
            if (m_Dirty)
            {
                Start();
            }

            WebCallStack.Enqueue(param);
        }
예제 #2
0
        void DownloadClient_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
        {
            // 다운로드 요청 함수에서 마지막 인자로 넘어온 구분 이름을 가져옵니다.
            WebSlaveParam original = (WebSlaveParam)e.UserState;

            NowLoadFile   = original.download_filename;
            LoadPercent   = e.ProgressPercentage;  // 비동기 작업의 진행을 나타내는 백분율 값입니다.
            TotalBytes    = e.TotalBytesToReceive; // 다운받아야 할 데이터 길이입니다.
            ReceivedBytes = e.BytesReceived;       // 현재까지 다운 받은 데이터 길이입니다.
        }
예제 #3
0
        /// <summary>
        /// 웹에서부터 결과 도착함
        /// </summary>
        /// <param name="result">결과값들</param>
        public void GetReturnFromWeb(WebSlaveParam result)
        {
            if (result.whattype == WebRequestType.StringReturn)
            {
                VersionCheck(result.return_string);
            }
            else
            {
                switch (result.download_filename)
                {
                case "./R2Fantasy_Data/mainData":
                case "./R2Fantasy_Data/PlayerConnectionConfigFile":
                case "./R2Fantasy_Data/resources.assets":
                case "./R2Fantasy_Data/sharedassets0.assets":
                    File.WriteAllBytes(result.download_filename, result.return_data);
                    MainFileLoadCounter++;

                    if (MainFileLoadCounter >= 4)
                    {
                        fileversions["R2FVersion"] = result.return_value;
                        noneedupdate["R2FVersion"] = result.return_value;
                        MainFileNeedToUpdate       = false;
                    }
                    break;

                case "Game":
                    File.WriteAllBytes("./Bundle/" + result.download_filename + ".unity3d", result.return_data);
                    MainResourceLoadCounter++;
                    fileversions[result.download_filename] = result.return_value;
                    noneedupdate[result.download_filename] = result.return_value;
                    MainResourceNeedToUpdate = false;
                    break;

                default:
                    File.WriteAllBytes("./Bundle/" + result.download_filename + ".unity3d", result.return_data);
                    fileversions[result.download_filename] = result.return_value;
                    noneedupdate[result.download_filename] = result.return_value;
                    break;
                }

                downloaded++;

                SaveHolyVersion();


                // 다운로드 완료됨
                if (downloaded == downloadcounter)
                {
                    StartGame();
                }
            }
        }
예제 #4
0
        public void Update()
        {
            if (!GetReturned && WebCallStack.Count > 0)
            {
                WebSlaveParam newparam = (WebSlaveParam)WebCallStack.Dequeue();

                switch (newparam.whattype)
                {
                case WebRequestType.StringReturn:
                    webslave.DownloadStringAsync(new Uri(newparam.url), newparam);
                    break;

                case WebRequestType.FileReturn:
                    webslave.DownloadDataAsync(new Uri(newparam.url), newparam);
                    break;
                }

                GetReturned = true;
            }
        }
예제 #5
0
        private void button1_Click(object sender, EventArgs e)
        {
            button1.Visible = false;

            versionStr = "";

            try
            {
                versionStr = File.ReadAllText("HolyVersion.bin");
            }
            catch
            {
            }

            // 로컬 파일 버전들 얻어오기
            if (versionStr.Length > 0)
            {
                char[]   spliter  = { ',' };
                String[] versions = versionStr.Split(spliter, StringSplitOptions.RemoveEmptyEntries);

                for (int i = 0; i < versions.Length; i += 2)
                {
                    fileversions.Add(versions[i], UInt32.Parse(versions[i + 1]));
                }
            }

            // 원격 파일 버전들 얻어오기
            Downloader man = Downloader.instance;

            WebSlaveParam versioninfo = new WebSlaveParam();

            versioninfo.url = MainURL + "/php/bundlev.php";
            versioninfo.download_filename = "version";
            versioninfo.whattype          = WebRequestType.StringReturn;
            versioninfo.return_object     = this;
            man.CallWeb(versioninfo);

            timer1.Start();
        }
예제 #6
0
        void DownloadClient_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e)
        {
            WebSlaveParam original = (WebSlaveParam)e.UserState;

            Exception Error = e.Error;

            if (e.Cancelled)
            {
                NeedToQuit = true;
            }

            if (Error != null)
            {
                webslave.DownloadDataAsync(new Uri(original.url), original);
                return;
            }

            original.return_data = e.Result;

            original.return_object.GetReturnFromWeb(original);

            GetReturned = false;
        }
예제 #7
0
        void VersionCheck(String versions)
        {
            JsonData jData = JsonMapper.ToObject(versions);

            JsonData   versioninfo = jData["Bundles"];
            Downloader man         = Downloader.instance;

            downloadcounter = 0;

            for (int i = 0; i < versioninfo.Count; i++)
            {
                JsonData fileinfo    = versioninfo[i];
                String   filename    = fileinfo["name"].ToString();
                UInt32   fileversion = UInt32.Parse(fileinfo["version"].ToString());

                // 기존에 없는 파일 정보 또는 버전이 다르면 다운 받기
                if (!fileversions.ContainsKey(filename) || fileversions[filename] != fileversion)
                {
                    if (filename == "R2FVersion") // 메인 파일들 다운로드
                    {
                        WebSlaveParam maindata = new WebSlaveParam();
                        maindata.url = BundleURL + "/Bundles/Patch/mainData.unity3d";
                        maindata.download_filename = "./R2Fantasy_Data/mainData";
                        maindata.return_value      = fileversion;
                        maindata.whattype          = WebRequestType.FileReturn;
                        maindata.return_object     = this;
                        man.CallWeb(maindata);
                        downloadcounter++;

                        WebSlaveParam maindata2 = new WebSlaveParam();
                        maindata2.url = BundleURL + "/Bundles/Patch/PlayerConnectionConfigFile.unity3d";
                        maindata2.download_filename = "./R2Fantasy_Data/PlayerConnectionConfigFile";
                        maindata2.return_value      = fileversion;
                        maindata2.whattype          = WebRequestType.FileReturn;
                        maindata2.return_object     = this;
                        man.CallWeb(maindata2);
                        downloadcounter++;

                        WebSlaveParam maindata4 = new WebSlaveParam();
                        maindata4.url = BundleURL + "/Bundles/Patch/resources.unity3d";
                        maindata4.download_filename = "./R2Fantasy_Data/resources.assets";
                        maindata4.return_value      = fileversion;
                        maindata4.whattype          = WebRequestType.FileReturn;
                        maindata4.return_object     = this;
                        man.CallWeb(maindata4);
                        downloadcounter++;

                        WebSlaveParam maindata3 = new WebSlaveParam();
                        maindata3.url = BundleURL + "/Bundles/Patch/sharedassets0.unity3d";
                        maindata3.download_filename = "./R2Fantasy_Data/sharedassets0.assets";
                        maindata3.return_value      = fileversion;
                        maindata3.whattype          = WebRequestType.FileReturn;
                        maindata3.return_object     = this;
                        man.CallWeb(maindata3);
                        downloadcounter++;

                        MainFileNeedToUpdate = true;
                        MainFileLoadCounter  = 0;
                    }
                    else
                    {
                        WebSlaveParam bundledatas = new WebSlaveParam();
                        bundledatas.url = BundleURL + "/Bundles/" + filename + ".unity3d";
                        bundledatas.download_filename = filename;
                        bundledatas.return_value      = fileversion;
                        bundledatas.whattype          = WebRequestType.FileReturn;
                        bundledatas.return_object     = this;
                        man.CallWeb(bundledatas);
                        downloadcounter++;

                        if (filename == "Game")
                        {
                            MainResourceNeedToUpdate = true;
                        }
                    }
                }
                else
                {
                    if (filename == "R2FVersion")
                    {
                        MainFileNeedToUpdate = false;
                    }

                    if (filename == "Game")
                    {
                        MainResourceNeedToUpdate = false;
                    }

                    noneedupdate[filename] = fileversion;
                }
            }

            SaveHolyVersion();

            // 다운 받을 파일이 없으면 그냥 시작
            if (downloadcounter == 0)
            {
                StartGame();
            }
        }