Cirrious.MvvmCross.Plugins.Sphero.HackFileShare.NonAwaitingConnectedSpheroRunner.ReceiveResponse C# (CSharp) Method

ReceiveResponse() private method

private ReceiveResponse ( ) : SpheroResponse
return Cirrious.MvvmCross.Plugins.Sphero.Messages.SpheroResponse
        private SpheroResponse ReceiveResponse()
        {
            var builder = new SpheroResponseBuilder();

            while (true)
            {
                byte x;

                try
                {
                    var task = _streamSpheroWrapper.ReceiveByte();
                    task.Start();
                    x = task.Result;
                }
                catch (AggregateException exception)
                {
                    throw exception.InnerException;
                }

                builder.Add(x);

                if (builder.IsErrored)
                {
                    throw new SpheroPluginException("Error reading packet {0}", builder.CurrentState);
                }

                if (builder.IsComplete)
                {
                    return builder.Response;
                }
            }
        }