Exemple #1
0
 /// <summary>
 /// Applies WebData response information to responseInfo
 /// </summary>
 /// <param name="webData"></param>
 protected virtual void FinilizeResponseInfo(IWebData webData)
 {
     ResponseInfo.ResponseUrl     = webData.ResponseInfo.ResponseUrl;
     ResponseInfo.ContentFilename = webData.ResponseInfo.ContentFilename;
     ResponseInfo.ContentLength   = webData.ResponseInfo.ContentLength;
     ResponseInfo.ContentType     = webData.ResponseInfo.ContentType;
 }
Exemple #2
0
        public override string Execute()
        {
            if (_UserOptions.RemoveScripts)
            {
                // no script is required
                return(string.Empty);
            }
            else
            {
                Encoding _encoding;
                string   resultCodes = StringStream.GetString(
                    WebData.ResponseData,
                    WebData.ResponseInfo.ContentType,
                    _UserOptions.ForceEncoding,
                    false,
                    out _encoding);
                ContentEncoding = _encoding;

                IWebData webData = (IWebData)WebData;

                // Execute the result
                Execute(ref resultCodes,
                        webData.ResponseInfo.ResponseUrl,
                        null, null,
                        webData.ResponseInfo.ResponseRootUrl);

                // the result
                return(resultCodes);
            }
        }
Exemple #3
0
    void Response(IWebData List, bool bError)
    {
        if (bError) // 에러 발생
        {
            // 종료
            ///Application.Quit();

            // TODO: _SENDLIST REMOVE
            _Sendlist.RemoveAt(0);
            Debug.Log("_Sendlist remove(" + _Sendlist.Count + ") + ERROR");

            _bBlockinput = false;
        }
        else
        {
            // TODO: _SENDLIST REMOVE
            _Sendlist.RemoveAt(0);
            Debug.Log("_Sendlist remove(" + _Sendlist.Count + ")");
            if (_Sendlist.Count > 0)    // 남아있으면 추가 전송
            {
                StartCoroutine(SendURL(_Sendlist[0]));
            }
            else
            {
                _bBlockinput = false;
            }
        }
    }
Exemple #4
0
 public void Dispose()
 {
     if (_webData != null)
     {
         _webData.Dispose();
     }
     _webData = null;
 }
        public TestingLogic(ILogger <TestingLogic> logger, IS3Data s3Data, IWebData webData, CustomJWT jwt)
        {
            _logger  = logger;
            _s3Data  = s3Data;
            _webData = webData;
            _sync    = new object();


            _client = new HttpClient(new HttpClientHandler()
            {
                AllowAutoRedirect = false
            });
            _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", jwt.CreateJWT());
        }
Exemple #6
0
    public void Send(IWebData SendData, bool blockinput)
    {
        _bBlockinput = blockinput;

        // TODO: _SENDLIST ADD
        _Sendlist.Add(SendData);
        Debug.Log("_Sendlist add(" + _Sendlist.Count + ")");
        if (_Sendlist.Count == 1)
        {
            // TODO: [Unity Script] StartCoroutine();
            // 코루틴 함수 호출
            StartCoroutine(SendURL(_Sendlist[0]));
        }
    }
Exemple #7
0
        protected override void ApplyWebDataRequestInfo(IWebData webData)
        {
            // call base emthod
            base.ApplyWebDataRequestInfo(webData);

            // ajax headers
            webData.RequestInfo.CustomHeaders = AjaxRequest.CustomHeaders;

            // Apply credentials
            if (string.IsNullOrEmpty(AjaxRequest.Username) == false)
            {
                string pass = "";
                if (AjaxRequest.Password != null)
                {
                    pass = AjaxRequest.Password;
                }

                // Set as a certificated request
                webData.RequestInfo.CertificatRequest(AjaxRequest.Username, pass);
            }
        }
Exemple #8
0
        protected virtual void ApplyWebDataRequestInfo(IWebData webData)
        {
            // Setting the referrer
            if (string.IsNullOrEmpty(RequestInfo.RedirectedFrom) == false)
            {
                webData.RequestInfo.Referrer      = RequestInfo.RedirectedFrom;
                webData.RequestInfo.ReferrerUsage = ReferrerType.Referrer;
            }
            else
            {
                if (RequestInfo.RequestUrlAsReferrer)
                {
                    webData.RequestInfo.ReferrerUsage = ReferrerType.RequesterAsReferrer;
                }
                else
                {
                    webData.RequestInfo.ReferrerUsage = ReferrerType.None;
                }
            }

            webData.RequestInfo.AcceptCookies     = UserOptions.Cookies;
            webData.RequestInfo.TempCookies       = UserOptions.TempCookies;
            webData.RequestInfo.IfModifiedSince   = RequestInfo.IfModifiedSince;
            webData.RequestInfo.CustomHeaders     = RequestInfo.CustomHeaders;
            webData.RequestInfo.RequestMethod     = RequestInfo.RequestMethod;
            webData.RequestInfo.PostDataString    = RequestInfo.PostDataString;
            webData.RequestInfo.ContentType       = RequestInfo.ContentTypeString;
            webData.RequestInfo.InputStream       = RequestInfo.InputStream;
            webData.RequestInfo.RequesterType     = RequestInfo.RequesterType;
            webData.RequestInfo.PrrocessErrorPage = RequestInfo.PrrocessErrorPage;
            webData.RequestInfo.BufferResponse    = RequestInfo.BufferResponse;

            webData.RequestInfo.RangeBegin   = RequestInfo.RangeBegin;
            webData.RequestInfo.RangeEnd     = RequestInfo.RangeEnd;
            webData.RequestInfo.RangeRequest = RequestInfo.RangeRequest;
        }
Exemple #9
0
 /// <summary>
 /// Applies WebData response information to responseInfo
 /// </summary>
 /// <param name="webData"></param>
 protected virtual void FinilizeResponseInfo(IWebData webData)
 {
     ResponseInfo.ResponseUrl = webData.ResponseInfo.ResponseUrl;
     ResponseInfo.ContentFilename = webData.ResponseInfo.ContentFilename;
     ResponseInfo.ContentLength = webData.ResponseInfo.ContentLength;
     ResponseInfo.ContentType = webData.ResponseInfo.ContentType;
 }
Exemple #10
0
        protected virtual void ApplyWebDataRequestInfo(IWebData webData)
        {
            // Setting the referrer
            if (string.IsNullOrEmpty(RequestInfo.RedirectedFrom) == false)
            {
                webData.RequestInfo.Referrer = RequestInfo.RedirectedFrom;
                webData.RequestInfo.ReferrerUsage = ReferrerType.Referrer;
            }
            else
            {
                if (RequestInfo.RequestUrlAsReferrer)
                    webData.RequestInfo.ReferrerUsage = ReferrerType.RequesterAsReferrer;
                else
                    webData.RequestInfo.ReferrerUsage = ReferrerType.None;
            }

            webData.RequestInfo.AcceptCookies = UserOptions.Cookies;
            webData.RequestInfo.TempCookies = UserOptions.TempCookies;
            webData.RequestInfo.IfModifiedSince = RequestInfo.IfModifiedSince;
            webData.RequestInfo.CustomHeaders = RequestInfo.CustomHeaders;
            webData.RequestInfo.RequestMethod = RequestInfo.RequestMethod;
            webData.RequestInfo.PostDataString = RequestInfo.PostDataString;
            webData.RequestInfo.ContentType = RequestInfo.ContentTypeString;
            webData.RequestInfo.InputStream = RequestInfo.InputStream;
            webData.RequestInfo.RequesterType = RequestInfo.RequesterType;
            webData.RequestInfo.PrrocessErrorPage = RequestInfo.PrrocessErrorPage;
            webData.RequestInfo.BufferResponse = RequestInfo.BufferResponse;

            webData.RequestInfo.RangeBegin = RequestInfo.RangeBegin;
            webData.RequestInfo.RangeEnd = RequestInfo.RangeEnd;
            webData.RequestInfo.RangeRequest = RequestInfo.RangeRequest;
        }
        public MangaDetailViewModel(IWebData service, ILocalData dataBase)
        {
            this.service = service;
            this.dataBase = dataBase;

            /* MOCKING! */
            //Manga = new Manga()
            //{
            //    Title = "Awesome manga",
            //    LocalSummaryImage = "ms-appx:/Assets/SOUL_EATER-Portada.jpg",
            //    ArtistsDb = string.Join("#", new List<string>() { "Awesome author 1", "Awesome author 2", "Awesome author 1" }),
            //    Description = "You think water moves fast? You should see ice. It moves like it has a mind. Like it knows it killed the world once and got a taste for murder. After the avalanche, it took us a week to climb out. Now, I don't know exactly when we turned on each other, but I know that seven of us survived the slide... and only five made it out. Now we took an oath, that I'm breaking now. We said we'd say it was the snow that killed the other two, but it wasn't. Nature is lethal but it doesn't hold a candle to man. /nYou think water moves fast? You should see ice. It moves like it has a mind. Like it knows it killed the world once and got a taste for murder. After the avalanche, it took us a week to climb out. Now, I don't know exactly when we turned on each other, but I know that seven of us survived the slide... and only five made it out. Now we took an oath, that I'm breaking now. We said we'd say it was the snow that killed the other two, but it wasn't. Nature is lethal but it doesn't hold a candle to man.",
            //    YearOfRelease = 9999,
            //    LastChapter = 10,
            //    StatusDb = 1,
            //};

            //var chapters = new List<Chapter>();
            //for (int i = 1; i <= 50; i++)
            //    chapters.Add(new Chapter() { Title = "Chapter" + i, Number = i });
            //this.dataBase.CreateInitialDb();
            Manga = dataBase.MangaList.First();
            service.GetMangaChapters(Manga);

            //LoadData();
        }
Exemple #12
0
        public void Dispose()
        {
			if (_webData != null)
				_webData.Dispose();
			_webData = null;
        }
Exemple #13
0
        protected override void ApplyWebDataRequestInfo(IWebData webData)
        {
			// call base emthod
            base.ApplyWebDataRequestInfo(webData);

            // ajax headers
            webData.RequestInfo.CustomHeaders = AjaxRequest.CustomHeaders;

            // Apply credentials
            if (string.IsNullOrEmpty(AjaxRequest.Username) == false)
            {
                string pass = "";
                if (AjaxRequest.Password != null)
                    pass = AjaxRequest.Password;

                // Set as a certificated request
                webData.RequestInfo.CertificatRequest(AjaxRequest.Username, pass);
            }

        }
Exemple #14
0
 public void Setup()
 {
     DataLogin = new Login("");
     webServ   = new WebService();
 }
Exemple #15
0
    /**********************************************************
     * TODO: [Unity Script] 코루틴(Coroutine)
     * Yield Process 개념. 특정 위치에서 실행을 일시 중단하고 다시 시작할 수 있는 여러 진입점을 허용하는 함수
     * `동시실행루틴`이라 부르나, 실제로는 두 가지 흐름을 병렬로 수행하는 것이 아니라 하나의 흐름을 기억했다가 수행
     *
     * - 작동 원리 : 코루틴(Coroutine)은 `단일쓰레드`지만 코루틴을 사용하여 `멀티쓰레드`처럼 작동.
     *              Update() 호출 시 yield return 할 코루틴이 있는지 확인. (Script_Lifecycle_Flowchart 참고)
     *
     * - 스레드와의 차이점 : 1. 스레드는 선점형(Preemptive), 코루틴은 비선점형(Non-Premmptive)
     *                       2. 스레드는 OS가 스케줄링, 코루틴은 유저레벨 스레드
     *                       3. 멀티스레드는 스레드가 2개 이상, 코루틴은 단일스레드
     *
     * - 서브루틴(subroutine) : 진입점과 중단점이 각각 하나씩인 코루틴
     *
     * - IEnumerable 인터페이스 :  단순히 GetEnumerator()를 구현하기 위한 인터페이스
     * public interface IEnumerable{
     *     IEnumerator GetEnumerator();    // 내부 데이터를 foreach 같은 것으로 열거할 수 있다
     * }
     *
     * - IEnumerator 함수 : 코루틴
     * public interface IEnumerator{
     *     object Current { get; }
     *     bool MoveNext();
     *     void Reset();
     * }
     *********************************************************/
    IEnumerator SendURL(IWebData SendData)
    {
        Debug.Log("REQUEST : " + (PHP_URL + SendData.URL()));

        //-----------------------------------------------------
        // SendData 클래스를 JSON 형식으로 변환
        //
        //-----------------------------------------------------
        UTF8Encoding utf8 = new UTF8Encoding();   // 유니코드 문자의 UTF-8 인코딩

        // TODO: [LitJson] JsonMapper.ToJson(this); 지정한 객체를 JSON 문자열로 변환하여 리턴
        string szJsonData = JsonMapper.ToJson(SendData);

        //-----------------------------------------------------
        // JSON 데이터 전송 및 결과 컨텐츠 수신
        //
        //-----------------------------------------------------
        // WWW 클래스 인자로 문자열 전달 불가능(포인터도, 메모리도 접근 불가능)
        // 따라서, String을 Byte로 Convert
        byte[] bytes = utf8.GetBytes(szJsonData);

        // TODO: [Unity Script] WWW 클래스; URL에 메세지를 보내고, 컨텐츠를 받아오는 유틸리티 모듈
        // * 요약 : 지정한 URL에 데이터를 POST 형식으로 Request를 보내고 그 컨텐츠를 받아옴. JSON으로 보낸 메시지이므로 웹페이지에서 JSON으로 받는 경우에만 작동
        // * 반환값 : 새로운 WWW 오브젝트(복사가 일어남). 컨텐츠 다운로드 완료시, 생성된 오브젝트로부터 그 결과를 가져올 수 있다(fetch)
        // * 문제점 : 웹 요청에 대한 반응이 바로 오지 않아서 일시적으로 유니티가 멈춤( = WWW를 OnClick으로 구현하면 안되는 이유!)
        //          -> Yield Process(유저레벨 스레드)로 빠져서 웹 처리를 하도록 해야함 = 유니티에서는 코루틴(Coroutine)
        WWW www = new WWW(PHP_URL + SendData.URL(), bytes);

        // * yield return : 현 상태 저장 후 리턴
        // * yield break : Iteration 루프 탈출
        yield return(www);   // 답이 오지 않으면 계속 돌면서 답이 왔는지 검사

        //////////////////////////////////////////////////////////////////////
        // * 작동 방식 예 :
        //public IEnumerator Call()
        //{
        //    string JSONStr = JsonMapper.ToJson(this);
        //    UTF8Encoding utf8 = new UTF8Encoding();
        //    byte[] JsonBytes = utf8.GetBytes(JSONStr);
        //
        //    WWW www = new WWW(szPath, JsonBytes);
        //
        //    yield return www;                     // 첫번째 루프에서 리턴
        //    Debug.Log("RESPONSE : " + www.text);  // 두번째 루프에서 실행
        //}
        //////////////////////////////////////////////////////////////////////

        //-----------------------------------------------------
        // 응답 처리
        //
        //-----------------------------------------------------
        Response(SendData, (www.error != null));    // www.error 값이 null이면 true, null이 아니면 false
        if (www.error == null)
        {
            //-----------------------------------------------------
            // Json 데이터 파싱
            //
            //-----------------------------------------------------
            /* TODO: !!주의!! php측에서 UTF8 + BOM 코드로 인코딩된 다른 php를 include할 경우 에러 발생 */
            JsonData JsonResponse = JsonMapper.ToObject(www.text);

            //-----------------------------------------------------
            // 기본적으로 ResultCode / ResultMsg가 있으므로 확인
            //
            //-----------------------------------------------------
            int    ResultCode = Convert.ToInt32(JsonResponse["ResultCode"].ToString());
            string ResultMsg  = JsonResponse["ResultMsg"].ToString();

            //-----------------------------------------------------
            // 각각의 WebData 내 Recv()에서 데이터 처리
            //
            //-----------------------------------------------------
            if (ResultCode == 1)
            {
                Debug.Log("RESPONSE : url:" + SendData.URL() + " | Contents:" + www.text);
                SendData.Recv(JsonResponse);
            }
            else
            {
                // 웹페이지 측에서 요청 처리 실패
                Debug.Log("RESPONSE : url:" + SendData.URL() + " | ResultCode:" + ResultCode + " | ResultMsg:" + ResultMsg);
                MessageBox(ResultMsg);
            }
        }
        else
        {
            // 전송 에러
            Debug.Log("REQUEST FAILED : url:" + SendData.URL() + " | error:" + www.error);
            MessageBox(www.error);
        }
    }
Exemple #16
0
 public static void SendMessage(IWebData SendData, bool bBlockinput)
 {
     INSTANCE().Send(SendData, bBlockinput);
 }
Exemple #17
0
 public void AfterHandshake(IEngine engine, IWebData webData)
 {
 }
Exemple #18
0
 public void BeforeHandshake(IEngine engine, IWebData webData)
 {
     //SalarSoft.ASProxy.UrlProvider.CorrectInputUrl
 }