using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace uPLibrary.Networking.M2Mqtt.Messages
{
///
/// Context for MQTT message
///
public class MqttMsgContext
{
///
/// MQTT message
///
public MqttMsgBase Message { get; set; }
///
/// MQTT message state
///
public MqttMsgState State { get; set; }
///
/// Flow of the message
///
public MqttMsgFlow Flow { get; set; }
///
/// Timestamp in ticks (for retry)
///
public int Timestamp { get; set; }
///
/// Attempt (for retry)
///
public int Attempt { get; set; }
///
/// Unique key
///
public string Key
{
get { return this.Flow + "_" + this.Message.MessageId; }
}
}
///
/// Flow of the message
///
public enum MqttMsgFlow
{
///
/// To publish to subscribers
///
ToPublish,
///
/// To acknowledge to publisher
///
ToAcknowledge
}
///
/// MQTT message state
///
public enum MqttMsgState
{
///
/// QOS = 0, Message queued
///
QueuedQos0,
///
/// QOS = 1, Message queued
///
QueuedQos1,
///
/// QOS = 2, Message queued
///
QueuedQos2,
///
/// QOS = 1, PUBLISH sent, wait for PUBACK
///
WaitForPuback,
///
/// QOS = 2, PUBLISH sent, wait for PUBREC
///
WaitForPubrec,
///
/// QOS = 2, PUBREC sent, wait for PUBREL
///
WaitForPubrel,
///
/// QOS = 2, PUBREL sent, wait for PUBCOMP
///
WaitForPubcomp,
///
/// QOS = 2, start first phase handshake send PUBREC
///
SendPubrec,
///
/// QOS = 2, start second phase handshake send PUBREL
///
SendPubrel,
///
/// QOS = 2, end second phase handshake send PUBCOMP
///
SendPubcomp,
///
/// QOS = 1, PUBLISH received, send PUBACK
///
SendPuback,
// [v3.1.1] SUBSCRIBE isn't "officially" QOS = 1
///
/// Send SUBSCRIBE message
///
SendSubscribe,
// [v3.1.1] UNSUBSCRIBE isn't "officially" QOS = 1
///
/// Send UNSUBSCRIBE message
///
SendUnsubscribe,
///
/// (QOS = 1), SUBSCRIBE sent, wait for SUBACK
///
WaitForSuback,
///
/// (QOS = 1), UNSUBSCRIBE sent, wait for UNSUBACK
///
WaitForUnsuback
}
}