Example #1
0
        private void retry()
        {
            if (!keepRetrying)
            {
                return;
            }

            HTTPRequest req = request.getClone();

            req.execute(HTTPCallback);

            if (retryPosition < retryDelayTable.Length && (!useDeadline || Time.realtimeSinceStartup < retryDeadline))
            {
                int delay = retryDelayTable[retryPosition++];

                if (delay > 0)
                {
                    AsyncExec.runWithDelay(delay, retry);
                }
                else
                {
                    keepRetrying = false;
                }
            }
            else
            {
                keepRetrying = false;
            }
        }
Example #2
0
    public override void init (string gameId, bool testModeEnabled, bool debugModeEnabled, string gameObjectName) {
	    if(initialized) return;
    	initialized = true;

      Utils.LogDebug ("UnityEditor: init(), gameId=" + gameId + ", testModeEnabled=" + testModeEnabled + ", gameObjectName=" + gameObjectName + ", debugModeEnabled=" + debugModeEnabled);

    	string url = "https://impact.applifier.com/mobile/campaigns?platform=editor&gameId=" + WWW.EscapeURL(gameId) + "&unityVersion=" + WWW.EscapeURL(Application.unityVersion);
    	HTTPRequest req = new HTTPRequest(url);
    	req.execute(handleResponse);

  	}
		public void downloadJson() {
			string requestURLString = requestURL();
			HTTPRequest jsonRequest = new HTTPRequest ("POST", requestURLString);
			jsonRequest.addHeader ("Content-Type", "application/json");
			string jsonInfo = jsonPayload();
			jsonRequest.setPayload (jsonInfo);
			jsonRequest.execute(response => {
        if(response.dataLength == 0) return;
        string jsonString = System.Text.Encoding.UTF8.GetString(response.data, 0, response.dataLength);
				EventManager.sendAdplanEvent(Engine.Instance.AppId);
				_jsonAvailable(jsonString);
				_operationCompleteDelegate();
			});
		}
    void Update() {
			if(!adIsShowing)
				return;
			float distinct = currentTime - previousTime;
			increase = distinct/animationDuration;
			if(!_isClosed)
				showAnimation ();
			else
				hideAnimation ();
      
      if(Input.GetMouseButtonDown(0)) {
        if(mouseInRect(texturesRects[screenOrientation][ImageType.CloseActiveArea])) {
          EventManager.sendCloseEvent(Engine.Instance.AppId, _ad.id, false);
          _isClosed = true;
          manager.pictureAdClosed();
          return;
       	}

        if(mouseInRect(texturesRects[screenOrientation][ImageType.Base])) {
          EventManager.sendClickEvent(Engine.Instance.AppId, _ad.id);
          HTTPRequest request = new HTTPRequest("POST", _ad.clickActionUrl);
          request.addHeader("Content-Type", "application/json");
          request.setPayload(DeviceInfo.getJson());
          request.execute((HTTPResponse response) => {
            if(response != null && response.data != null) {
              string jsonString = System.Text.Encoding.UTF8.GetString(response.data, 0, response.dataLength);
              object jsonObject = MiniJSON.Json.Deserialize(jsonString);
              if(jsonObject != null && jsonObject is Dictionary<string, object>) {
                Dictionary<string, object> json = (Dictionary<string, object>)jsonObject;
                string redirectLocation = (string)json["clickUrl"];
                if(redirectLocation != null) {
                  Application.OpenURL(redirectLocation);
                }
              }
            }
          });
          return;
        }
      }
			previousTime = currentTime;
			currentTime = Time.realtimeSinceStartup;
    }
		void executeRequestForResource(PictureAd ad, ImageOrientation imageOrientation, ImageType imageType) {
			string filePath = ad.getLocalImageURL(imageOrientation, imageType);
			if (System.IO.File.Exists(filePath)) {
				downloadedResourcesCount++;
				if(downloadedResourcesCount == PictureAd.expectedResourcesCount) {
					_resourcesAvailable ();
					_operationCompleteDelegate();
				}
				return;
			}
			string url = ad.getRemoteImageURL(imageOrientation, imageType);
			HTTPRequest pictureURLRequest = new HTTPRequest(url);
			pictureURLRequest.execute(pictureURLRequestResponse => {
				downloadedResourcesCount ++;
				if(pictureURLRequestResponse.dataLength != 0)
					System.IO.File.WriteAllBytes(ad.getLocalImageURL(imageOrientation, imageType), pictureURLRequestResponse.data);
				
				if(downloadedResourcesCount == PictureAd.expectedResourcesCount) {
					_resourcesAvailable ();
					_operationCompleteDelegate();
				}
			});
		}