Exemplo n.º 1
0
        public void OpenRequest(int id, string url, string method, string head, string body = null, string contentType = null,
                                int timeOut = 10000, OnTaskDone cb = null)
        {
            WebTask task = new WebTask(url, method, head, body, contentType, timeOut, cb);

            GetWorker(id).AddTask(task);
        }
Exemplo n.º 2
0
        public HttpUpLoadTask(string _url, string[] header, string _uploadFile, string fileKey, string _saveName, bool addInfo,
                              bool _compress, string _contentType, int _timeOut, OnTaskDone _cb)
            : base(_cb)
        {
            url          = _url;
            this.header  = header;
            uploadFile   = _uploadFile;
            this.fileKey = fileKey;

            if (addInfo)
            {
                string time = DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss");
                saveName = string.Format("[{0}][{1}]{2}", time, Application.platform, _saveName);
            }
            else
            {
                saveName = _saveName;
            }
            compress = _compress;
            if (string.IsNullOrEmpty(_contentType))
            {
                contentType = "application/octet-stream";
            }
            else
            {
                contentType = _contentType;
            }
            timeOut = _timeOut;
        }
Exemplo n.º 3
0
 public override void UpdateExec()
 {
     if (cb != null)
     {
         cb(isSuccess, ret);
         cb = null;
     }
 }
Exemplo n.º 4
0
 public WebTask(string _url, string _method, string _head, string _body, string _contentType,
                int _timeOut, OnTaskDone _cb) : base(_cb)
 {
     url         = _url;
     method      = _method;
     head        = _head;
     body        = _body;
     timeOut     = _timeOut;
     contentType = _contentType;
 }
Exemplo n.º 5
0
 // Update is called once per frame
 void Update()
 {
     if (Time.frameCount % 4 == 0 && onGoingProject)
     {
         CheckBars();
         if (AllBarsAreDone())
         {
             onGoingProject = false;
             resourcesManager.AddGold(Mathf.RoundToInt(currentGoldReward * AbilityManager.instance.GoldMultiplier));
             if (isGameJam)
             {
                 resourcesManager.GameJamDone();
             }
             OnTaskDone?.Invoke();
             spawnerScript.RequestNewProject();
         }
     }
 }
Exemplo n.º 6
0
 public void WebRequestGet(string url, OnTaskDone cb, int id = 0)
 {
     OpenRequest(id, url, "GET", null, null, null, 10000, cb);
 }
Exemplo n.º 7
0
        public void DownloadFile(int id, string url, string savePath, int timeOut, OnTaskDone cb)
        {
            HttpDownloadTask task = new HttpDownloadTask(url, savePath, timeOut, cb);

            GetWorker(id).AddTask(task);
        }
Exemplo n.º 8
0
        public void UploadFile(int id, string url, string uploadFile, string fileKey, string saveName, bool addPre = false, bool compress = false,
                               string contentType = null, string[] header = null, int timeOut = 10000, OnTaskDone cb = null)
        {
            HttpUpLoadTask task = new HttpUpLoadTask(url, header, uploadFile, fileKey, saveName, addPre, compress, contentType, timeOut, cb);

            GetWorker(id).AddTask(task);
        }
Exemplo n.º 9
0
 public HttpDownloadTask(string _url, string _savePath, int _timeOut, OnTaskDone _cb) : base(_cb)
 {
     url      = _url;
     savePath = _savePath;
     timeOut  = _timeOut;
 }
Exemplo n.º 10
0
 public WebCbTask(OnTaskDone _cb)
 {
     cb        = _cb;
     ret       = null;
     isSuccess = false;
 }