|
@@ -40,13 +40,13 @@ load(Opts) ->
|
|
|
emqttd:hook('message.publish', fun ?MODULE:rewrite_publish/2, [Sections])
|
|
emqttd:hook('message.publish', fun ?MODULE:rewrite_publish/2, [Sections])
|
|
|
end.
|
|
end.
|
|
|
|
|
|
|
|
-rewrite_subscribe(_ClientId, TopicTable, Sections) ->
|
|
|
|
|
- lager:info("Rewrite subscribe: ~p", [TopicTable]),
|
|
|
|
|
- {ok, [{match_topic(Topic, Sections), Qos} || {Topic, Qos} <- TopicTable]}.
|
|
|
|
|
|
|
+rewrite_subscribe({_ClientId, _Username}, {Topic, Opts}, Sections) ->
|
|
|
|
|
+ lager:info("Rewrite subscribe: ~p", [{Topic, Opts}]),
|
|
|
|
|
+ {ok, {match_topic(Topic, Sections), Opts}}.
|
|
|
|
|
|
|
|
-rewrite_unsubscribe(_ClientId, Topics, Sections) ->
|
|
|
|
|
- lager:info("Rewrite unsubscribe: ~p", [Topics]),
|
|
|
|
|
- {ok, [match_topic(Topic, Sections) || Topic <- Topics]}.
|
|
|
|
|
|
|
+rewrite_unsubscribe({_ClientId, _Username}, {Topic, Opts}, Sections) ->
|
|
|
|
|
+ lager:info("Rewrite unsubscribe: ~p", [{Topic, Opts}]),
|
|
|
|
|
+ {ok, {match_topic(Topic, Sections), Opts}}.
|
|
|
|
|
|
|
|
rewrite_publish(Message=#mqtt_message{topic = Topic}, Sections) ->
|
|
rewrite_publish(Message=#mqtt_message{topic = Topic}, Sections) ->
|
|
|
%%TODO: this will not work if the client is always online.
|
|
%%TODO: this will not work if the client is always online.
|