//check msg public static CommonRet getJsonObj(string msg) { CommonRet o = new CommonRet(); try { o = UmsJson.Deserialize<CommonRet>(msg); } catch (Exception e) { DebugTool.Log(e.Message); } if (o == null) { DebugTool.Log("invaild return"); } return o; }
private void GetResponseCallback(IAsyncResult asynchronousResult) { HttpWebRequest request = (HttpWebRequest)asynchronousResult.AsyncState; HttpWebResponse response = null; try { response = (HttpWebResponse)request.EndGetResponse(asynchronousResult); } catch (Exception e) { DebugTool.Log(e.InnerException.Message); } if (response == null) { CommonRet errorRet = new CommonRet(); errorRet.flag = "-100"; errorRet.msg = "server is not founded."; ret = UmsJson.Serialize(errorRet); DebugTool.Log(ret); stateChanged(type, ret, obj); return; } Stream streamResponse = response.GetResponseStream(); StreamReader streamRead = new StreamReader(streamResponse); string responseString = streamRead.ReadToEnd(); // Close the stream object streamResponse.Close(); streamRead.Close(); ret = responseString; stateChanged(type, ret, obj); }