public void downloadJson()
 {
     string requestURLString = requestURL();
     HTTPRequest jsonRequest = new HTTPRequest ("POST", requestURLString);
     jsonRequest.addHeader ("Content-Type", "application/json");
     string jsonInfo = jsonPayload();
     jsonRequest.setPayload (jsonInfo);
     HTTPManager.sendRequest(jsonRequest, HTTPJsonCallback, retryDelays, 20 * 60);
 }
Пример #2
0
    public void execute(System.Action<bool> eventCallback) {
      callback = eventCallback;

      HTTPRequest req = new HTTPRequest("POST", url);
      req.addHeader("Content-Type", "application/json");
      req.setPayload(jsonData);

      HTTPManager.sendRequest(req, HTTPCallback, retryDelayTable, deadlineDelay);
    }
		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;
    }