MqttMsgContext.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /*
  2. Copyright (c) 2013, 2014 Paolo Patierno
  3. All rights reserved. This program and the accompanying materials
  4. are made available under the terms of the Eclipse Public License v1.0
  5. and Eclipse Distribution License v1.0 which accompany this distribution.
  6. The Eclipse Public License is available at
  7. http://www.eclipse.org/legal/epl-v10.html
  8. and the Eclipse Distribution License is available at
  9. http://www.eclipse.org/org/documents/edl-v10.php.
  10. Contributors:
  11. Paolo Patierno - initial API and implementation and/or initial documentation
  12. */
  13. using System;
  14. using System.Text;
  15. namespace uPLibrary.Networking.M2Mqtt.Messages
  16. {
  17. /// <summary>
  18. /// Context for MQTT message
  19. /// </summary>
  20. public class MqttMsgContext
  21. {
  22. /// <summary>
  23. /// MQTT message
  24. /// </summary>
  25. public MqttMsgBase Message { get; set; }
  26. /// <summary>
  27. /// MQTT message state
  28. /// </summary>
  29. public MqttMsgState State { get; set; }
  30. /// <summary>
  31. /// Flow of the message
  32. /// </summary>
  33. public MqttMsgFlow Flow { get; set; }
  34. /// <summary>
  35. /// Timestamp in ticks (for retry)
  36. /// </summary>
  37. public int Timestamp { get; set; }
  38. /// <summary>
  39. /// Attempt (for retry)
  40. /// </summary>
  41. public int Attempt { get; set; }
  42. }
  43. /// <summary>
  44. /// Flow of the message
  45. /// </summary>
  46. public enum MqttMsgFlow
  47. {
  48. /// <summary>
  49. /// To publish to subscribers
  50. /// </summary>
  51. ToPublish,
  52. /// <summary>
  53. /// To acknowledge to publisher
  54. /// </summary>
  55. ToAcknowledge
  56. }
  57. /// <summary>
  58. /// MQTT message state
  59. /// </summary>
  60. public enum MqttMsgState
  61. {
  62. /// <summary>
  63. /// QOS = 0, Message queued
  64. /// </summary>
  65. QueuedQos0,
  66. /// <summary>
  67. /// QOS = 1, Message queued
  68. /// </summary>
  69. QueuedQos1,
  70. /// <summary>
  71. /// QOS = 2, Message queued
  72. /// </summary>
  73. QueuedQos2,
  74. /// <summary>
  75. /// QOS = 1, PUBLISH sent, wait for PUBACK
  76. /// </summary>
  77. WaitForPuback,
  78. /// <summary>
  79. /// QOS = 2, PUBLISH sent, wait for PUBREC
  80. /// </summary>
  81. WaitForPubrec,
  82. /// <summary>
  83. /// QOS = 2, PUBREC sent, wait for PUBREL
  84. /// </summary>
  85. WaitForPubrel,
  86. /// <summary>
  87. /// QOS = 2, PUBREL sent, wait for PUBCOMP
  88. /// </summary>
  89. WaitForPubcomp,
  90. /// <summary>
  91. /// QOS = 2, start first phase handshake send PUBREC
  92. /// </summary>
  93. SendPubrec,
  94. /// <summary>
  95. /// QOS = 2, start second phase handshake send PUBREL
  96. /// </summary>
  97. SendPubrel,
  98. /// <summary>
  99. /// QOS = 2, end second phase handshake send PUBCOMP
  100. /// </summary>
  101. SendPubcomp,
  102. /// <summary>
  103. /// QOS = 1, PUBLISH received, send PUBACK
  104. /// </summary>
  105. SendPuback,
  106. // [v3.1.1] SUBSCRIBE isn't "officially" QOS = 1
  107. /// <summary>
  108. /// Send SUBSCRIBE message
  109. /// </summary>
  110. SendSubscribe,
  111. // [v3.1.1] UNSUBSCRIBE isn't "officially" QOS = 1
  112. /// <summary>
  113. /// Send UNSUBSCRIBE message
  114. /// </summary>
  115. SendUnsubscribe,
  116. /// <summary>
  117. /// (QOS = 1), SUBSCRIBE sent, wait for SUBACK
  118. /// </summary>
  119. WaitForSuback,
  120. /// <summary>
  121. /// (QOS = 1), UNSUBSCRIBE sent, wait for UNSUBACK
  122. /// </summary>
  123. WaitForUnsuback
  124. }
  125. }