emqtt/include/emqtt.hrl
This commit is contained in:
parent
99633fb815
commit
d50507475a
|
@ -20,7 +20,7 @@
|
|||
%% SOFTWARE.
|
||||
%%------------------------------------------------------------------------------
|
||||
%%% @doc
|
||||
%%% emqttd header.
|
||||
%%% MQTT Broker Header.
|
||||
%%%
|
||||
%%% @end
|
||||
%%%-----------------------------------------------------------------------------
|
||||
|
@ -86,24 +86,6 @@
|
|||
|
||||
-type mqtt_session() :: #mqtt_session{}.
|
||||
|
||||
%%------------------------------------------------------------------------------
|
||||
%% MQTT Message
|
||||
%%------------------------------------------------------------------------------
|
||||
|
||||
-type mqtt_msgid() :: undefined | 1..16#ffff.
|
||||
|
||||
-record(mqtt_message, {
|
||||
%% topic is first for message may be retained
|
||||
topic :: binary(),
|
||||
qos = 0 :: 0 | 1 | 2,
|
||||
retain = false :: boolean(),
|
||||
dup = false :: boolean(),
|
||||
msgid :: mqtt_msgid(),
|
||||
payload :: binary()
|
||||
}).
|
||||
|
||||
-type mqtt_message() :: #mqtt_message{}.
|
||||
|
||||
%%------------------------------------------------------------------------------
|
||||
%% MQTT Plugin
|
||||
%%------------------------------------------------------------------------------
|
||||
|
@ -114,4 +96,6 @@
|
|||
description
|
||||
}).
|
||||
|
||||
-type mqtt_plugin() :: #mqtt_plugin{}.
|
||||
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
-behaviour(gen_server).
|
||||
|
||||
-include_lib("emqtt/include/emqtt_packet.hrl").
|
||||
-include_lib("emqtt/include/emqtt.hrl").
|
||||
|
||||
-include("emqttd.hrl").
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
%%%-----------------------------------------------------------------------------
|
||||
-module(emqttd_broker).
|
||||
|
||||
-include("emqttd.hrl").
|
||||
-include_lib("emqtt/include/emqtt.hrl").
|
||||
|
||||
-include("emqttd_systop.hrl").
|
||||
|
||||
|
|
|
@ -39,10 +39,12 @@
|
|||
code_change/3,
|
||||
terminate/2]).
|
||||
|
||||
-include("emqttd.hrl").
|
||||
-include_lib("emqtt/include/emqtt.hrl").
|
||||
|
||||
-include_lib("emqtt/include/emqtt_packet.hrl").
|
||||
|
||||
-include("emqttd.hrl").
|
||||
|
||||
%%Client State...
|
||||
-record(state, {transport,
|
||||
socket,
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
%%%-----------------------------------------------------------------------------
|
||||
-module(emqttd_event).
|
||||
|
||||
-include("emqttd.hrl").
|
||||
-include_lib("emqtt/include/emqtt.hrl").
|
||||
|
||||
%% API Function Exports
|
||||
-export([start_link/0,
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
-author('feng@emqtt.io').
|
||||
|
||||
-include_lib("emqtt/include/emqtt_packet.hrl").
|
||||
-include_lib("emqtt/include/emqtt.hrl").
|
||||
|
||||
-include("emqttd.hrl").
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
|
||||
-include("emqttd.hrl").
|
||||
|
||||
-include_lib("emqtt/include/emqtt.hrl").
|
||||
-include_lib("emqtt/include/emqtt_packet.hrl").
|
||||
|
||||
-export([from_packet/1, to_packet/1]).
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
-author('feng@emqtt.io').
|
||||
|
||||
-include("emqttd.hrl").
|
||||
-include_lib("emqtt/include/emqtt.hrl").
|
||||
|
||||
-include("emqttd_systop.hrl").
|
||||
|
||||
|
|
|
@ -26,10 +26,11 @@
|
|||
%%%-----------------------------------------------------------------------------
|
||||
-module(emqttd_protocol).
|
||||
|
||||
-include("emqttd.hrl").
|
||||
|
||||
-include_lib("emqtt/include/emqtt.hrl").
|
||||
-include_lib("emqtt/include/emqtt_packet.hrl").
|
||||
|
||||
-include("emqttd.hrl").
|
||||
|
||||
%% API
|
||||
-export([init/2, clientid/1]).
|
||||
|
||||
|
|
|
@ -28,14 +28,16 @@
|
|||
|
||||
-author('feng@emqtt.io').
|
||||
|
||||
-include("emqttd.hrl").
|
||||
-include_lib("emqtt/include/emqtt.hrl").
|
||||
|
||||
-include_lib("emqtt/include/emqtt_packet.hrl").
|
||||
-include("emqttd.hrl").
|
||||
|
||||
-behaviour(gen_server).
|
||||
|
||||
-define(SERVER, ?MODULE).
|
||||
|
||||
-define(SUBACK_ERR, 128).
|
||||
|
||||
%% Mnesia Callbacks
|
||||
-export([mnesia/1]).
|
||||
|
||||
|
@ -115,13 +117,14 @@ create(Topic) when is_binary(Topic) ->
|
|||
-spec subscribe({Topic, Qos} | list({Topic, Qos})) -> {ok, Qos | list(Qos)} when
|
||||
Topic :: binary(),
|
||||
Qos :: mqtt_qos().
|
||||
subscribe(Topics = [{_Topic, _Qos}|_]) ->
|
||||
subscribe(Topics = [{_Topic, _Qos} | _]) ->
|
||||
{ok, lists:map(fun({Topic, Qos}) ->
|
||||
case subscribe(Topic, Qos) of
|
||||
{ok, GrantedQos} ->
|
||||
GrantedQos;
|
||||
Error ->
|
||||
lager:error("Failed to subscribe '~s': ~p", [Topic, Error]), ?QOS_ERR
|
||||
lager:error("Failed to subscribe '~s': ~p", [Topic, Error]),
|
||||
?SUBACK_ERR
|
||||
end
|
||||
end, Topics)}.
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
-module(emqttd_queue).
|
||||
|
||||
-include("emqttd.hrl").
|
||||
-include_lib("emqtt/include/emqtt.hrl").
|
||||
|
||||
-export([new/1, new/2, in/3, all/1, clear/1]).
|
||||
|
||||
|
@ -66,7 +66,7 @@ in(ClientId, Message = #mqtt_message{qos = Qos},
|
|||
Wrapper#mqtt_queue_wrapper{queue = queue:in(Message, Queue)};
|
||||
false -> % full
|
||||
if
|
||||
Qos =:= 0 ->
|
||||
Qos =:= ?QOS_0 ->
|
||||
lager:warning("Queue ~s drop qos0 message: ~p", [ClientId, Message]),
|
||||
Wrapper;
|
||||
true ->
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
-author('feng@slimpp.io').
|
||||
|
||||
-include("emqttd.hrl").
|
||||
-include_lib("emqtt/include/emqtt.hrl").
|
||||
|
||||
%% Mnesia callbacks
|
||||
-export([mnesia/1]).
|
||||
|
|
|
@ -23,7 +23,8 @@
|
|||
%%route chain... statistics
|
||||
-module(emqttd_router).
|
||||
|
||||
-include("emqttd.hrl").
|
||||
-include_lib("emqtt/include/emqtt.hrl").
|
||||
%-include("emqttd.hrl").
|
||||
|
||||
-behaviour(gen_server).
|
||||
|
||||
|
|
|
@ -26,9 +26,9 @@
|
|||
%%%-----------------------------------------------------------------------------
|
||||
-module(emqttd_session).
|
||||
|
||||
-include("emqttd.hrl").
|
||||
|
||||
-include_lib("emqtt/include/emqtt.hrl").
|
||||
-include_lib("emqtt/include/emqtt_packet.hrl").
|
||||
-include("emqttd.hrl").
|
||||
|
||||
%% API Function Exports
|
||||
-export([start/1,
|
||||
|
|
Loading…
Reference in New Issue