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;
}
}
}