コード例 #1
0
        /// <summary>
        /// Handle a 'Remove allowed device' response.
        /// </summary>
        /// <param name="packet">The packet to check.</param>
        private void HandleRemoveAllowedResponse(CommandData packet)
        {
            try
            {
                Beacon receivedBeacon = RiderIDCommandDataParser.ParseAllowedDeviceOperationResponse(packet.Status, packet.Data);

                if (packet.Status == 0)
                {
                    this.knownRiders.RemoveAll(rid => rid.Beacon.Equals(receivedBeacon));
                }
                else
                {
                    Log.Warn("Failure while removing rider");
                }
            }
            catch (Exception ex)
            {
                Log.Error($"Received bad response for {packet.CommandType} command", ex);
            }
        }
コード例 #2
0
        /// <summary>
        /// Handle a 'Add allowed device' response.
        /// </summary>
        /// <param name="packet">The packet to check.</param>
        private void HandleAddAllowedResponse(CommandData packet)
        {
            try
            {
                Beacon receivedBeacon = RiderIDCommandDataParser.ParseAllowedDeviceOperationResponse(packet.Status, packet.Data);

                if (packet.Status == 0)
                {
                    if (this.knownRiders.Any(rid => rid.Beacon.Equals(receivedBeacon)))
                    {
                        Log.Info($"Successfully added rider {this.knownRiders.First(rid => rid.Beacon.Equals(receivedBeacon)).Name} with beacon {receivedBeacon}");
                    }
                }
                else
                {
                    Log.Warn("Failure while adding rider");
                }
            }
            catch (Exception ex)
            {
                Log.Error($"Received bad response for {packet.CommandType} command", ex);
            }
        }