protected void RemovePendingAcknowledgement(string clientId, ushort packetId, MqttPacketType type)
        {
            ClientSession session = sessionRepository.Read(clientId);

            if (session == null)
            {
                throw new MqttException(ClientProperties.SessionRepository_ClientSessionNotFound(clientId));
            }

            PendingAcknowledgement pendingAcknowledgement = session
                                                            .GetPendingAcknowledgements()
                                                            .FirstOrDefault(u => u.Type == type && u.PacketId == packetId);

            session.RemovePendingAcknowledgement(pendingAcknowledgement);

            sessionRepository.Update(session);
        }
Beispiel #2
0
        void SavePendingAcknowledgement(IFlowPacket ack, string clientId)
        {
            if (ack.Type != MqttPacketType.PublishReceived && ack.Type != MqttPacketType.PublishRelease)
            {
                return;
            }

            var unacknowledgeMessage = new PendingAcknowledgement {
                PacketId = ack.PacketId,
                Type     = ack.Type
            };

            var session = sessionRepository.Get(s => s.ClientId == clientId);

            if (session == null)
            {
                throw new MqttException(string.Format(Properties.Resources.SessionRepository_ClientSessionNotFound, clientId));
            }

            session.AddPendingAcknowledgement(unacknowledgeMessage);

            sessionRepository.Update(session);
        }
        void SavePendingAcknowledgement(IFlowPacket ack, string clientId)
        {
            if (ack.Type != MqttPacketType.PublishReceived && ack.Type != MqttPacketType.PublishRelease)
            {
                return;
            }

            PendingAcknowledgement unacknowledgeMessage = new PendingAcknowledgement
            {
                PacketId = ack.PacketId,
                Type     = ack.Type
            };

            ClientSession session = sessionRepository.Read(clientId);

            if (session == null)
            {
                throw new MqttException(ClientProperties.SessionRepository_ClientSessionNotFound(clientId));
            }

            session.AddPendingAcknowledgement(unacknowledgeMessage);

            sessionRepository.Update(session);
        }