Merge pull request #864 from grutabow/master
Hook 'client.unsubscribe' need to handle 'stop'
This commit is contained in:
commit
eb05cfdca9
|
@ -130,9 +130,12 @@ handle({subscribe, RawTopicTable}, ProtoState = #proto_state{client_id = ClientI
|
||||||
handle({unsubscribe, RawTopics}, ProtoState = #proto_state{client_id = ClientId,
|
handle({unsubscribe, RawTopics}, ProtoState = #proto_state{client_id = ClientId,
|
||||||
username = Username,
|
username = Username,
|
||||||
session = Session}) ->
|
session = Session}) ->
|
||||||
{ok, TopicTable} = emqttd:run_hooks('client.unsubscribe',
|
case emqttd:run_hooks('client.unsubscribe', [ClientId, Username], parse_topics(RawTopics)) of
|
||||||
[ClientId, Username], parse_topics(RawTopics)),
|
{ok, TopicTable} ->
|
||||||
emqttd_session:unsubscribe(Session, TopicTable),
|
emqttd_session:unsubscribe(Session, TopicTable);
|
||||||
|
{stop, _} ->
|
||||||
|
ok
|
||||||
|
end,
|
||||||
{ok, ProtoState}.
|
{ok, ProtoState}.
|
||||||
|
|
||||||
process(Packet = ?CONNECT_PACKET(Var), State0) ->
|
process(Packet = ?CONNECT_PACKET(Var), State0) ->
|
||||||
|
@ -243,8 +246,12 @@ process(?UNSUBSCRIBE_PACKET(PacketId, []), State) ->
|
||||||
|
|
||||||
process(?UNSUBSCRIBE_PACKET(PacketId, RawTopics), State = #proto_state{
|
process(?UNSUBSCRIBE_PACKET(PacketId, RawTopics), State = #proto_state{
|
||||||
client_id = ClientId, username = Username, session = Session}) ->
|
client_id = ClientId, username = Username, session = Session}) ->
|
||||||
{ok, TopicTable} = emqttd:run_hooks('client.unsubscribe', [ClientId, Username], parse_topics(RawTopics)),
|
case emqttd:run_hooks('client.unsubscribe', [ClientId, Username], parse_topics(RawTopics)) of
|
||||||
emqttd_session:unsubscribe(Session, TopicTable),
|
{ok, TopicTable} ->
|
||||||
|
emqttd_session:unsubscribe(Session, TopicTable);
|
||||||
|
{stop, _} ->
|
||||||
|
ok
|
||||||
|
end,
|
||||||
send(?UNSUBACK_PACKET(PacketId), State);
|
send(?UNSUBACK_PACKET(PacketId), State);
|
||||||
|
|
||||||
process(?PACKET(?PINGREQ), State) ->
|
process(?PACKET(?PINGREQ), State) ->
|
||||||
|
|
Loading…
Reference in New Issue