public static Response ParseResponse(Request request, byte[] responseBytes) { var response = new Response(); response.RawBytes = responseBytes; response.Request = request; var header = ProtocolHeader.CreateResponseHeader(responseBytes); response.Header = header; if (header.IsOk && header.PayloadSize > 0) { var offset = ProtocolHeader.HeaderSize + header.PayloadOffset; response.Payload = ParsePayload(responseBytes, offset); } else { response.Payload = new Payload(); } return response; }
private void OnResponse(Response response, object context) { OutputText = string.Empty; Output = new DiagnosticInfo(response).ToString(); try { if (response.Payload.PayloadCode == PayloadCode.Rexpression) { var rexp = ProtocolParser.ParseRexpression(response.Payload.Content); if (rexp.IsStringList) { var list = rexp.ToStringList(); foreach (var s in list) { OutputText += string.Format("{0}\n", s); } } if (rexp.IsDoubleList) { var list = rexp.ToDoubleList(); foreach (var d in list) { OutputText += string.Format("{0}\n", d); } } } } catch (Exception e) { Output += string.Format("\n\n(TODO) this response is currently unhandled, raising an exception: {0}\n", e); } }
private void OnResponse(Response response, object context) { Deployment.Current.Dispatcher.BeginInvoke(() => { AppViewModel.OutputText = string.Empty; Output = new DiagnosticInfo(response).ToString(); try { if (response.Payload.PayloadCode == PayloadCode.Rexpression) { var rexp = ProtocolParser.ParseRexpression(response.Payload.Content); if (rexp.HasAttribute) { var tags = rexp.HasAttribute ? rexp.Attribute.ToListTags() : null; var tagstr = rexp.Attribute.ToFormattedString(); } AppViewModel.OutputText += rexp.ToFormattedString(); } } catch (Exception e) { Output += string.Format("\n\n(TODO) this response is currently unhandled, raising an exception: {0}\n", e); } }); }
public DiagnosticInfo(Response response) { Response = response; }