emqttd.hrl 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. %%------------------------------------------------------------------------------
  2. %% Copyright (c) 2012-2015, Feng Lee <feng@emqtt.io>
  3. %%
  4. %% Permission is hereby granted, free of charge, to any person obtaining a copy
  5. %% of this software and associated documentation files (the "Software"), to deal
  6. %% in the Software without restriction, including without limitation the rights
  7. %% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. %% copies of the Software, and to permit persons to whom the Software is
  9. %% furnished to do so, subject to the following conditions:
  10. %%
  11. %% The above copyright notice and this permission notice shall be included in all
  12. %% copies or substantial portions of the Software.
  13. %%
  14. %% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. %% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. %% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. %% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. %% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. %% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  20. %% SOFTWARE.
  21. %%------------------------------------------------------------------------------
  22. %%% @doc
  23. %%% MQTT Broker Header.
  24. %%%
  25. %%% @end
  26. %%%-----------------------------------------------------------------------------
  27. %%------------------------------------------------------------------------------
  28. %% Banner
  29. %%------------------------------------------------------------------------------
  30. -define(COPYRIGHT, "Copyright (C) 2012-2015, Feng Lee <feng@emqtt.io>").
  31. -define(LICENSE_MESSAGE, "Licensed under MIT").
  32. -define(PROTOCOL_VERSION, "MQTT/3.1.1").
  33. -define(ERTS_MINIMUM, "6.0").
  34. %%------------------------------------------------------------------------------
  35. %% PubSub
  36. %%------------------------------------------------------------------------------
  37. -type pubsub() :: publish | subscribe.
  38. %%------------------------------------------------------------------------------
  39. %% MQTT Topic
  40. %%------------------------------------------------------------------------------
  41. -record(mqtt_topic, {
  42. topic :: binary(),
  43. node :: node()
  44. }).
  45. -type mqtt_topic() :: #mqtt_topic{}.
  46. %%------------------------------------------------------------------------------
  47. %% MQTT Subscriber
  48. %%------------------------------------------------------------------------------
  49. -record(mqtt_subscriber, {
  50. topic :: binary(),
  51. qos = 0 :: 0 | 1 | 2,
  52. pid :: pid()
  53. }).
  54. -type mqtt_subscriber() :: #mqtt_subscriber{}.
  55. %%------------------------------------------------------------------------------
  56. %% P2P Queue Subscriber
  57. %%------------------------------------------------------------------------------
  58. -record(mqtt_queue, {
  59. name :: binary(),
  60. subpid :: pid(),
  61. qos = 0 :: 0 | 1 | 2
  62. }).
  63. -type mqtt_queue() :: #mqtt_queue{}.
  64. %%------------------------------------------------------------------------------
  65. %% MQTT Client
  66. %%------------------------------------------------------------------------------
  67. -record(mqtt_client, {
  68. clientid :: binary(),
  69. username :: binary() | undefined,
  70. ipaddr :: inet:ip_address()
  71. }).
  72. -type mqtt_client() :: #mqtt_client{}.
  73. %%------------------------------------------------------------------------------
  74. %% MQTT Session
  75. %%------------------------------------------------------------------------------
  76. -record(mqtt_session, {
  77. clientid,
  78. session_pid,
  79. subscriptions = [],
  80. awaiting_ack,
  81. awaiting_rel
  82. }).
  83. -type mqtt_session() :: #mqtt_session{}.
  84. %%------------------------------------------------------------------------------
  85. %% MQTT Plugin
  86. %%------------------------------------------------------------------------------
  87. -record(mqtt_plugin, {
  88. name,
  89. version,
  90. attrs,
  91. description
  92. }).
  93. -type mqtt_plugin() :: #mqtt_plugin{}.