Просмотр исходного кода

Fixed issue #1314. re-sent retained messages when create/replace Subscription

- re-sent message when create a new Subscription relationship
- re-sent message when replace an existed Subscription with different Qos
HeeeJianBo 8 лет назад
Родитель
Сommit
84d8eae37e
1 измененных файлов с 2 добавлено и 1 удалено
  1. 2 1
      src/emqttd_session.erl

+ 2 - 1
src/emqttd_session.erl

@@ -389,14 +389,15 @@ handle_cast({subscribe, _From, TopicTable, AckFun},
                         SubMap;
                     {ok, OldQos} ->
                         emqttd:setqos(Topic, ClientId, NewQos),
+                        emqttd_hooks:run('session.subscribed', [ClientId, Username], {Topic, Opts}),
                         ?LOG(warning, "Duplicated subscribe ~s, old_qos=~w, new_qos=~w",
                             [Topic, OldQos, NewQos], State),
                         maps:put(Topic, NewQos, SubMap);
                     error ->
                         emqttd:subscribe(Topic, ClientId, Opts),
+                        emqttd_hooks:run('session.subscribed', [ClientId, Username], {Topic, Opts}),
                         maps:put(Topic, NewQos, SubMap)
                 end,
-                emqttd_hooks:run('session.subscribed', [ClientId, Username], {Topic, Opts}),
                 {[NewQos|QosAcc], SubMap1}
         end, {[], Subscriptions}, TopicTable),
     AckFun(lists:reverse(GrantedQos)),