public void RegisterOutgoingFlow(OutgoingFlow outgoingMessage) { using (var command = conn.CreateCommand()) { command.CommandText = @"INSERT INTO outgoing_flows (packet_id, retain, topic, qos, payload, received) VALUES (@packet_id, @retain, @topic, @qos, @payload, @received)" ; command.Parameters.AddWithValue("@packet_id", outgoingMessage.PacketId); command.Parameters.AddWithValue("@retain", outgoingMessage.Retain); command.Parameters.AddWithValue("@topic", outgoingMessage.Topic); command.Parameters.AddWithValue("@qos", (int)outgoingMessage.Qos); command.Parameters.AddWithValue("@payload", outgoingMessage.Payload); command.Parameters.AddWithValue("@received", false); command.ExecuteNonQuery(); } }
private void Resume(OutgoingFlow flow) { if (flow.Qos == MqttQos.AtLeastOnce || (flow.Qos == MqttQos.ExactlyOnce && !flow.Received)) { PublishPacket publish = new PublishPacket() { PacketId = flow.PacketId, QosLevel = flow.Qos, Topic = flow.Topic, Message = flow.Payload, DupFlag = true }; Publish(publish); } else if (flow.Qos == MqttQos.ExactlyOnce && flow.Received) { Pubrel(flow.PacketId); } Persistence.LastOutgoingPacketId = flow.PacketId; }