Skip to content

Commit

Permalink
Merge pull request #864 from grutabow/master
Browse files Browse the repository at this point in the history
Hook 'client.unsubscribe' need to handle 'stop'
  • Loading branch information
Feng Lee committed Jan 17, 2017
2 parents 72ed291 + 4606eae commit eb05cfd
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/emqttd_protocol.erl
Expand Up @@ -130,9 +130,12 @@ handle({subscribe, RawTopicTable}, ProtoState = #proto_state{client_id = ClientI
handle({unsubscribe, RawTopics}, ProtoState = #proto_state{client_id = ClientId,
username = Username,
session = Session}) ->
{ok, TopicTable} = emqttd:run_hooks('client.unsubscribe',
[ClientId, Username], parse_topics(RawTopics)),
emqttd_session:unsubscribe(Session, TopicTable),
case emqttd:run_hooks('client.unsubscribe', [ClientId, Username], parse_topics(RawTopics)) of
{ok, TopicTable} ->
emqttd_session:unsubscribe(Session, TopicTable);
{stop, _} ->
ok
end,
{ok, ProtoState}.

process(Packet = ?CONNECT_PACKET(Var), State0) ->
Expand Down Expand Up @@ -243,8 +246,12 @@ process(?UNSUBSCRIBE_PACKET(PacketId, []), State) ->

process(?UNSUBSCRIBE_PACKET(PacketId, RawTopics), State = #proto_state{
client_id = ClientId, username = Username, session = Session}) ->
{ok, TopicTable} = emqttd:run_hooks('client.unsubscribe', [ClientId, Username], parse_topics(RawTopics)),
emqttd_session:unsubscribe(Session, TopicTable),
case emqttd:run_hooks('client.unsubscribe', [ClientId, Username], parse_topics(RawTopics)) of
{ok, TopicTable} ->
emqttd_session:unsubscribe(Session, TopicTable);
{stop, _} ->
ok
end,
send(?UNSUBACK_PACKET(PacketId), State);

process(?PACKET(?PINGREQ), State) ->
Expand Down

0 comments on commit eb05cfd

Please sign in to comment.