public int Add(SubscriptionItem item)
        {
            if (Contains(item))
            {
                throw new ArgumentException("An item with this topic name already exists.");
            }

            return(_list.Add(item));
        }
Example #2
0
        /// <summary>
        /// Saves a message into the store and begins the response timer. If the message is not pulled from the store
        /// before the response timer ends, the MessageTimeout event is fired.
        /// </summary>
        /// <param name="message">The message sent to the remote endpoint. I.e. Publish, Subscribe, etc.</param>
        /// <param name="eventData">Client defined data associated with the message.</param>
        /// <param name="clientUid">The socket connection context.</param>
        public void Add(IMqttMessage message, object eventData, string clientUid)
        {
            var storeData = new MessageStoreData
            {
                Message       = message,
                MessageId     = MqttMessageBase.GetMessageIdOrDefault(message),
                EventData     = eventData,
                ResponseTimer = new TimeoutTimer(MqttProtocolInformation.Settings.NetworkTimeout),
                ClientUid     = clientUid
            };

            lock (_lock)
            {
                _pendingMessageData.Add(storeData);
            }

            storeData.ResponseTimer.TimeOutData = storeData;
            storeData.ResponseTimer.Timeout    += ResponseTimerOnTimeout;
            storeData.ResponseTimer.Start();
        }
        private void ReadPayload()
        {
            lock (_msg.SyncLock)
            {
                if (!_msg.PayloadRead)
                {
                    int pos = ReadVariableHeader();

                    var nameArray = new AutoExpandingArray();
                    while (pos < _msg.MsgBuffer.Length)
                    {
                        string topicName = Frame.DecodeString(_msg.MsgBuffer, ref pos);
                        nameArray.Add(topicName);
                    }

                    _topicNames = new string[nameArray.Count];
                    for (int i = 0; i < nameArray.Count; i++)
                    {
                        _topicNames[i] = (string)nameArray.GetAt(i);
                    }

                    _msg.PayloadRead = true;
                }
            }
        }
Example #4
0
 public int Add(QualityOfService qos)
 {
     return(_list.Add(qos));
 }