MissionPlanner.MAVLinkInterface.SubscribeToPacketType C# (CSharp) Method

SubscribeToPacketType() public method

public SubscribeToPacketType ( MAVLINK_MSG_ID type, bool>.Func function, bool exclusive = false ) : KeyValuePair>
type MAVLINK_MSG_ID
function bool>.Func
exclusive bool
return KeyValuePair>
        public KeyValuePair<MAVLINK_MSG_ID, Func<MAVLinkMessage, bool>> SubscribeToPacketType(MAVLINK_MSG_ID type,
            Func<MAVLinkMessage, bool> function, bool exclusive = false)
        {
            var item = new KeyValuePair<MAVLINK_MSG_ID, Func<MAVLinkMessage, bool>>(type, function);

            lock (Subscriptions)
            {
                if (exclusive)
                {
                    foreach (var subitem in Subscriptions)
                    {
                        if (subitem.Key == item.Key)
                        {
                            Subscriptions.Remove(subitem);
                            break;
                        }
                    }
                }

                log.Info("SubscribeToPacketType " + item.Key + " " + item.Value);

                Subscriptions.Add(item);
            }

            return item;
        }