chore(lint): fix elvis
This commit is contained in:
parent
c89dad559e
commit
f06ec6baaa
|
@ -50,6 +50,8 @@
|
||||||
|
|
||||||
-record(state, {peername, clientid, username, password, sub_topics = [], connected_at}).
|
-record(state, {peername, clientid, username, password, sub_topics = [], connected_at}).
|
||||||
|
|
||||||
|
-type(state() :: #state{}).
|
||||||
|
|
||||||
-define(ALIVE_INTERVAL, 20000).
|
-define(ALIVE_INTERVAL, 20000).
|
||||||
|
|
||||||
-define(CONN_STATS, [recv_pkt, recv_msg, send_pkt, send_msg]).
|
-define(CONN_STATS, [recv_pkt, recv_msg, send_pkt, send_msg]).
|
||||||
|
@ -74,8 +76,10 @@ client_pid(ClientId, Username, Password, Channel) ->
|
||||||
start(ClientId, Username, Password, Channel) ->
|
start(ClientId, Username, Password, Channel) ->
|
||||||
% DO NOT use start_link, since multiple coap_reponsder may have relation with one mqtt adapter,
|
% DO NOT use start_link, since multiple coap_reponsder may have relation with one mqtt adapter,
|
||||||
% one coap_responder crashes should not make mqtt adapter crash too
|
% one coap_responder crashes should not make mqtt adapter crash too
|
||||||
% And coap_responder is not a system process, it is dangerous to link mqtt adapter to coap_responder
|
% And coap_responder is not a system process
|
||||||
gen_server:start({via, emqx_coap_registry, {ClientId, Username, Password}}, ?MODULE, {ClientId, Username, Password, Channel}, []).
|
% it is dangerous to link mqtt adapter to coap_responder
|
||||||
|
gen_server:start({via, emqx_coap_registry, {ClientId, Username, Password}},
|
||||||
|
?MODULE, {ClientId, Username, Password, Channel}, []).
|
||||||
|
|
||||||
stop(Pid) ->
|
stop(Pid) ->
|
||||||
gen_server:stop(Pid).
|
gen_server:stop(Pid).
|
||||||
|
@ -164,7 +168,8 @@ handle_cast(Msg, State) ->
|
||||||
?LOG(error, "broker_api unexpected cast ~p", [Msg]),
|
?LOG(error, "broker_api unexpected cast ~p", [Msg]),
|
||||||
{noreply, State, hibernate}.
|
{noreply, State, hibernate}.
|
||||||
|
|
||||||
handle_info({deliver, _Topic, #message{topic = Topic, payload = Payload}}, State = #state{sub_topics = Subscribers}) ->
|
handle_info({deliver, _Topic, #message{topic = Topic, payload = Payload}},
|
||||||
|
State = #state{sub_topics = Subscribers}) ->
|
||||||
deliver([{Topic, Payload}], Subscribers),
|
deliver([{Topic, Payload}], Subscribers),
|
||||||
{noreply, State, hibernate};
|
{noreply, State, hibernate};
|
||||||
|
|
||||||
|
@ -211,7 +216,8 @@ chann_subscribe(Topic, State = #state{clientid = ClientId}) ->
|
||||||
emqx_broker:subscribe(Topic, ClientId, ?SUBOPTS),
|
emqx_broker:subscribe(Topic, ClientId, ?SUBOPTS),
|
||||||
emqx_hooks:run('session.subscribed', [clientinfo(State), Topic, ?SUBOPTS]);
|
emqx_hooks:run('session.subscribed', [clientinfo(State), Topic, ?SUBOPTS]);
|
||||||
deny ->
|
deny ->
|
||||||
?LOG(warning, "subscribe to ~p by clientid ~p failed due to acl check.", [Topic, ClientId])
|
?LOG(warning, "subscribe to ~p by clientid ~p failed due to acl check.",
|
||||||
|
[Topic, ClientId])
|
||||||
end.
|
end.
|
||||||
|
|
||||||
chann_unsubscribe(Topic, State) ->
|
chann_unsubscribe(Topic, State) ->
|
||||||
|
@ -228,7 +234,8 @@ chann_publish(Topic, Payload, State = #state{clientid = ClientId}) ->
|
||||||
emqx_message:set_flag(retain, false,
|
emqx_message:set_flag(retain, false,
|
||||||
emqx_message:make(ClientId, ?QOS_0, Topic, Payload)));
|
emqx_message:make(ClientId, ?QOS_0, Topic, Payload)));
|
||||||
deny ->
|
deny ->
|
||||||
?LOG(warning, "publish to ~p by clientid ~p failed due to acl check.", [Topic, ClientId])
|
?LOG(warning, "publish to ~p by clientid ~p failed due to acl check.",
|
||||||
|
[Topic, ClientId])
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
||||||
|
@ -253,7 +260,8 @@ deliver_to_coap(TopicName, Payload, [{TopicFilter, {IsWild, CoapPid}}|T]) ->
|
||||||
true -> emqx_topic:match(TopicName, TopicFilter);
|
true -> emqx_topic:match(TopicName, TopicFilter);
|
||||||
false -> TopicName =:= TopicFilter
|
false -> TopicName =:= TopicFilter
|
||||||
end,
|
end,
|
||||||
%?LOG(debug, "deliver_to_coap Matched=~p, CoapPid=~p, TopicName=~p, Payload=~p, T=~p", [Matched, CoapPid, TopicName, Payload, T]),
|
%?LOG(debug, "deliver_to_coap Matched=~p, CoapPid=~p, TopicName=~p, Payload=~p, T=~p",
|
||||||
|
% [Matched, CoapPid, TopicName, Payload, T]),
|
||||||
Matched andalso (CoapPid ! {dispatch, TopicName, Payload}),
|
Matched andalso (CoapPid ! {dispatch, TopicName, Payload}),
|
||||||
deliver_to_coap(TopicName, Payload, T).
|
deliver_to_coap(TopicName, Payload, T).
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue