Browse Source

chore: don't send subscribe msg if topic list is empty

JianBo He 4 năm trước cách đây
mục cha
commit
cc3a4f0c5f
1 tập tin đã thay đổi với 6 bổ sung2 xóa
  1. 6 2
      apps/emqx_auto_subscribe/src/emqx_auto_subscribe.erl

+ 6 - 2
apps/emqx_auto_subscribe/src/emqx_auto_subscribe.erl

@@ -60,8 +60,12 @@ test(_) ->
 %% hook
 
 on_client_connected(ClientInfo, ConnInfo, {TopicHandler, Options}) ->
-    TopicTables = erlang:apply(TopicHandler, handle, [ClientInfo, ConnInfo, Options]),
-    self() ! {subscribe, TopicTables};
+    case erlang:apply(TopicHandler, handle, [ClientInfo, ConnInfo, Options]) of
+        [] -> ok;
+        TopicTables ->
+            _ = self() ! {subscribe, TopicTables},
+            ok
+    end;
 on_client_connected(_, _, _) ->
     ok.