コード例 #1
0
        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]);
        }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
 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;
 }
コード例 #4
0
 public SpheroResponseBuilder()
 {
     _response = new SpheroResponse();
     _currentState = State.WaitingForSop1;
 }
コード例 #5
0
 public SpheroResponseBuilder()
 {
     _response     = new SpheroResponse();
     _currentState = State.WaitingForSop1;
 }