Exemple #1
0
        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);
            }
        }
Exemple #3
0
        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);
                }
            });
        }
Exemple #4
0
 public DiagnosticInfo(Response response)
 {
     Response = response;
 }