Merge pull request #868 from emqtt/emq20

Merge PR #864 from grutabow
This commit is contained in:
Feng Lee 2017-01-17 10:40:18 +08:00 committed by GitHub
commit 153ed22da5
1 changed files with 12 additions and 5 deletions

View File

@ -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) ->
@ -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) ->