public override ISpheroMessage ProcessResponse(SpheroResponse response) { if (response.Payload.Count != 3) { // TODO - report error... return null; } return new ColorMessage(response.Payload[0], response.Payload[1], response.Payload[2]); }
private void ProcessCommandResponse(SpheroResponse response) { CommandWithActions actions; lock (this) { if (!_responseListeners.TryGetValue(response.SequenceNumber, out actions)) { // TODO - some trace here would be fab return; } _responseListeners.Remove(response.SequenceNumber); } if (actions == null) return; try { ISpheroMessage message = actions.Command.ProcessResponse(response); actions.OnSuccess(message); } catch (Exception exception) { actions.OnError(exception); } }
public virtual ISpheroMessage ProcessResponse(SpheroResponse response) { // default behaviour is SimpleResponse // - any valid response packet is a good response. // - and returned message is empty return null; }
public SpheroResponseBuilder() { _response = new SpheroResponse(); _currentState = State.WaitingForSop1; }