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);
            }
        }
Пример #2
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);
 }
Пример #3
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]));
        }