contributors
This commit is contained in:
parent
be0adc14c3
commit
9d5223dd1a
12
README.md
12
README.md
|
@ -102,12 +102,12 @@ The MIT License (MIT)
|
||||||
|
|
||||||
## Contributors
|
## Contributors
|
||||||
|
|
||||||
[@hejin1026](https://github.com/hejin1026)
|
* [@hejin1026](https://github.com/hejin1026)
|
||||||
[@desoulter](https://github.com/desoulter)
|
* [@desoulter](https://github.com/desoulter)
|
||||||
[@turtleDeng](https://github.com/turtleDeng)
|
* [@turtleDeng](https://github.com/turtleDeng)
|
||||||
[@Hades32](https://github.com/Hades32)
|
* [@Hades32](https://github.com/Hades32)
|
||||||
[@huangdan](https://github.com/huangdan)
|
* [@huangdan](https://github.com/huangdan)
|
||||||
[@callbay](https://github.com/callbay)
|
* [@callbay](https://github.com/callbay)
|
||||||
|
|
||||||
|
|
||||||
## Author
|
## Author
|
||||||
|
|
|
@ -173,17 +173,31 @@ puback(SessPid, {?PUBCOMP, PacketId}) when is_pid(SessPid) ->
|
||||||
%%------------------------------------------------------------------------------
|
%%------------------------------------------------------------------------------
|
||||||
-spec subscribe(session(), [{binary(), mqtt_qos()}]) -> {ok, session(), [mqtt_qos()]}.
|
-spec subscribe(session(), [{binary(), mqtt_qos()}]) -> {ok, session(), [mqtt_qos()]}.
|
||||||
subscribe(SessState = #session_state{clientid = ClientId, submap = SubMap}, Topics) ->
|
subscribe(SessState = #session_state{clientid = ClientId, submap = SubMap}, Topics) ->
|
||||||
Resubs = [Topic || {Name, _Qos} = Topic <- Topics, maps:is_key(Name, SubMap)],
|
|
||||||
case Resubs of
|
%% subscribe first and don't care if the subscriptions have been existed
|
||||||
[] -> ok;
|
|
||||||
_ -> lager:warning("~s resubscribe ~p", [ClientId, Resubs])
|
|
||||||
end,
|
|
||||||
SubMap1 = lists:foldl(fun({Name, Qos}, Acc) -> maps:put(Name, Qos, Acc) end, SubMap, Topics),
|
|
||||||
{ok, GrantedQos} = emqttd_pubsub:subscribe(Topics),
|
{ok, GrantedQos} = emqttd_pubsub:subscribe(Topics),
|
||||||
|
|
||||||
lager:info([{client, ClientId}], "Client ~s subscribe ~p. Granted QoS: ~p",
|
lager:info([{client, ClientId}], "Client ~s subscribe ~p. Granted QoS: ~p",
|
||||||
[ClientId, Topics, GrantedQos]),
|
[ClientId, Topics, GrantedQos]),
|
||||||
%%TODO: should be gen_event and notification...
|
|
||||||
[emqttd_msg_store:redeliver(Name, self()) || {Name, _} <- Topics],
|
|
||||||
|
%% <MQTT V3.1.1>: 3.8.4
|
||||||
|
%% Where the Topic Filter is not identical to any existing Subscription’s filter,
|
||||||
|
%% a new Subscription is created and all matching retained messages are sent.
|
||||||
|
lists:foreach(fun({Name, _Qos}) ->
|
||||||
|
case maps:is_key(Name, SubMap) of
|
||||||
|
true ->
|
||||||
|
lager:warning("~s resubscribe ~p", [ClientId, Name]);
|
||||||
|
false ->
|
||||||
|
%%TODO: this is not right, rewrite later...
|
||||||
|
emqttd_msg_store:redeliver(Name, self())
|
||||||
|
end
|
||||||
|
end, Topics),
|
||||||
|
|
||||||
|
SubMap1 = lists:foldl(fun({Name, Qos}, Acc) ->
|
||||||
|
maps:put(Name, Qos, Acc)
|
||||||
|
end, SubMap, Topics),
|
||||||
|
|
||||||
{ok, SessState#session_state{submap = SubMap1}, GrantedQos};
|
{ok, SessState#session_state{submap = SubMap1}, GrantedQos};
|
||||||
|
|
||||||
subscribe(SessPid, Topics) when is_pid(SessPid) ->
|
subscribe(SessPid, Topics) when is_pid(SessPid) ->
|
||||||
|
|
Loading…
Reference in New Issue