protected override object IComplete(object param) { WebRequestCompleteArg arg = (WebRequestCompleteArg)param; bool success = (arg.result == WebResult.Complete && arg.resultCode < 300); Result result = new Result(); result.success = success; result.userState = userState; try { string str = UnpackString(arg.responseBody); if (success) { if (DeSoapify(ref str)) { result.thumbnailBytes = Convert.FromBase64String(str); } } str = null; } catch { result.success = false; } GC.Collect(); return(result); }
protected override object IComplete(object param) { WebRequestCompleteArg arg = (WebRequestCompleteArg)param; bool success = (arg.result == WebResult.Complete && arg.resultCode < 300); Result result = new Result(); result.success = success; result.userState = userState; try { string str = string.Empty; if (arg.responseBody != null) { str = Encoding.ASCII.GetString(arg.responseBody); } if (success) { if (DeSoapify(ref str)) { // B64 decode the return value. byte[] buffer = Convert.FromBase64String(str); // Decrypt the buffer. buffer = CryptoHelper.Decrypt(GetSymmetricAlgorithm(), buffer); // Deserialize the reply. Message_GetFacebookUserReply reply = Message_GetFacebookUserReply.Load(buffer); // Load result object with reply values. result.success = reply.ResultCode == ResultCode.Success; if (result.success) { result.facebookResultCode = reply.FacebookResultCode; result.facebookUser = reply.FacebookUser; } } else { result.success = false; } } } catch { result.success = false; } return(result); }
protected override object IComplete(object param) { WebRequestCompleteArg arg = (WebRequestCompleteArg)param; bool success = (arg.result == WebResult.Complete && arg.resultCode < 300); Result result = new Result(); result.success = success; result.userState = userState; try { string str = UnpackString(arg.responseBody); if (success) { if (DeSoapify(ref str)) { // B64 decode the return value. byte[] buffer = Convert.FromBase64String(str); // Deserialize the reply. Message_GetSearchWorldPageReply reply = Message_GetSearchWorldPageReply.Load(buffer); // Load result object with reply values. result.success = reply.ResultCode == ResultCode.Success; result.page = reply.Page; } else { result.success = false; } } } catch { result.success = false; } // The buffers used above can be quite large (multi-megs in size), // so force a collection now to avoid them piling up waiting to // be collected later. GC.Collect(); return(result); }
protected override object IComplete(object param) { WebRequestCompleteArg arg = (WebRequestCompleteArg)param; bool success = (arg.result == WebResult.Complete && arg.resultCode < 300); Result result = new Result(); result.success = success; result.userState = userState; try { string str = UnpackString(arg.responseBody); if (success) { if (DeSoapify(ref str)) { // B64 decode the return value. byte[] buffer = Convert.FromBase64String(str); // Deserialize the reply. Message_GetWebUserReply reply = Message_GetWebUserReply.Load(buffer); // Load result object with reply values. result.success = reply.ResultCode == ResultCode.Success; if (result.success) { result.koduWebUser = reply.KoduUser; } } else { result.success = false; } } } catch { result.success = false; } return(result); }
protected override object IComplete(object param) { WebRequestCompleteArg arg = (WebRequestCompleteArg)param; bool success = (arg.result == WebResult.Complete && arg.resultCode < 300); Result result = new Result(); result.success = success; result.userState = userState; try { string str = UnpackString(arg.responseBody); if (success) { if (DeSoapify(ref str)) { // B64 decode the return value. byte[] buffer = Convert.FromBase64String(str); // Deserialize the reply. Message_Hello2Reply reply = Message_Hello2Reply.Load(buffer); // Set results to data from reply result.symmetricIndex = reply.Index; } else { result.success = false; } } } catch { result.success = false; } return(result); }
void request_GetResponse(IAsyncResult ar) { try { response = (HttpWebResponse)request.EndGetResponse(ar); Stream stream = response.GetResponseStream(); StreamReader reader = new StreamReader(stream); string result = reader.ReadToEnd(); byte[] buffer = Encoding.UTF8.GetBytes(result); WebRequestCompleteArg arg = new WebRequestCompleteArg(); arg.result = WebResult.Complete; arg.responseBody = buffer; arg.resultCode = (int)response.StatusCode; OnComplete(arg); } catch { OnComplete(null); } }
protected override object IComplete(object param) { WebRequestCompleteArg arg = (WebRequestCompleteArg)param; bool success = (arg.result == WebResult.Complete && arg.resultCode < 300); Result result = new Result(); result.success = success; result.userState = userState; try { string str = UnpackString(arg.responseBody); } catch { result.success = false; } return(result); }
protected override object IComplete(object param) { WebRequestCompleteArg arg = (WebRequestCompleteArg)param; bool success = (arg.result == WebResult.Complete && arg.resultCode < 300); Result result = new Result(); result.success = success; result.userState = userState; try { string str = UnpackString(arg.responseBody); if (success) { if (DeSoapify(ref str)) { // B64 decode the return value. byte[] buffer = Convert.FromBase64String(str); result.version = Message_Version.Load(buffer); } else { result.success = false; } } } catch { result.success = false; } return(result); }
private void OnComplete(object param) { progress.Complete(); if (aborted) { return; } if (canceled) { WebRequestCompleteArg arg = new WebRequestCompleteArg(); arg.result = WebResult.ErrCanceled; param = arg; } else if (param == null) { WebRequestCompleteArg arg = new WebRequestCompleteArg(); arg.result = WebResult.ErrConnectFailed; param = arg; } EnqueueCompletion(this, param); }