//网络下载任务 private void RunDownloadTask(SSHttpTask task) { bool failure = httpClient.doDownload(task.request, task.filePath); if (!failure) { AsyncTask.QueueOnMainThread(() => { task.handleMainThreadCompleted(); }); } else { AsyncTask.QueueOnMainThread(() => { task.handleErrorOcurr(); }); } }
private void RunCommon(SSHttpTask task) { string acknowlege = httpClient.doRequest(task.request); //Check if we need response or not. if (!string.IsNullOrEmpty(acknowlege)) { task.response = acknowlege.Trim(); AsyncTask.QueueOnMainThread(() => { task.handleMainThreadCompleted(); }); } else { // error ocurr task.response = UNABLE_GET_RESPONSE; AsyncTask.QueueOnMainThread(() => { task.handleErrorOcurr(); }); } }
// void http_onReceieve (SSHttpTask task, string acknowlege) // { // if (task.request is HttpRequest) { // if (Utils.checkJsonFormat (acknowlege)) { // HttpResponseFactory.createResponse (task, acknowlege); // AsyncTask.QueueOnMainThread( () => { task.handleMainThreadCompleted(); } ); // // // } else // { // http_onException (task, acknowlege); // } // // } else if (task.request is ThirdPartyHttpRequest) { // task.response = new ThirdPartyResponse (acknowlege); // AsyncTask.QueueOnMainThread( () => { task.handleMainThreadCompleted(); } ); // // // } else if (task.request is HttpDownloadRequest) { // // task.response = new HttpDownloadResponse (); // AsyncTask.QueueOnMainThread( () => { task.handleMainThreadCompleted(); } ); // // } // // } // All http error will go through this routine. // Handle exception void http_onException(SSHttpTask task, string message) { task.response = message; AsyncTask.QueueOnMainThread(() => { task.handleErrorOcurr(); }); }