Skip to content

Commit 20e8358

Browse files
committed
🐛 [HDK-8201] Emqx: fixing emqx plugin.
- Updating emqx plugin.
1 parent 4ed9f66 commit 20e8358

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

src/ubidots_emqx_plugin.erl

+6-13
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
%% no need for this include if we call emqx_message:to_map/1 to convert it to a map
55
-include_lib("emqx/include/emqx.hrl").
66
-include_lib("emqx/include/emqx_hooks.hrl").
7-
-include_lib("hocon/include/hoconsc.hrl").
87
%% for logging
98
-include_lib("emqx/include/logger.hrl").
109

@@ -15,17 +14,16 @@
1514
%% Client Lifecycle Hooks
1615
-export([on_client_subscribe/4, on_client_unsubscribe/4]).
1716
%% Session Lifecycle Hooks
18-
-export([on_session_subscribed/5]).
17+
-export([on_session_subscribed/4]).
1918
%% Message Pubsub Hooks
2019
-export([on_message_delivered/3]).
2120

2221
%% Called when the plugin application start
2322
load(Env) ->
2423
ubidots_emqx_retainer_ecpool:start_pools(?POOL_REACTOR, ?POOL_CORE, Env),
25-
Config = #{pool_reactor => ?POOL_REACTOR, pool_core => ?POOL_CORE},
2624
hook('client.subscribe', {?MODULE, on_client_subscribe, [Env]}),
2725
hook('client.unsubscribe', {?MODULE, on_client_unsubscribe, [Env]}),
28-
hook('session.subscribed', {?MODULE, on_session_subscribed, [Env, Config]}),
26+
hook('session.subscribed', {?MODULE, on_session_subscribed, [Env]}),
2927
hook('message.delivered', {?MODULE, on_message_delivered, [Env]}).
3028

3129
%%--------------------------------------------------------------------
@@ -52,16 +50,11 @@ on_client_unsubscribe(#{username := UserName}, _Properties, TopicFilters, _Env)
5250
%% Session Lifecycle Hooks
5351
%%--------------------------------------------------------------------
5452

55-
on_session_subscribed(_, _, #{share := ShareName}, _Env, _Config)
56-
when ShareName =/= undefined ->
53+
on_session_subscribed(_, _, #{share := ShareName}, _Env) when ShareName =/= undefined ->
5754
ok;
58-
on_session_subscribed(_, Topic, #{rh := Rh, is_new := IsNew}, Env, Config) ->
59-
case Rh =:= 0 orelse Rh =:= 1 andalso IsNew of
60-
true ->
61-
emqx_pool:async_submit(fun dispatch/4, [self(), Topic, Env, Config]);
62-
_ ->
63-
ok
64-
end.
55+
on_session_subscribed(_, Topic, _Message, Env) ->
56+
Config = #{pool_reactor => ?POOL_REACTOR, pool_core => ?POOL_CORE},
57+
emqx_pool:async_submit(fun dispatch/4, [self(), Topic, Env, Config]).
6558

6659
dispatch(Pid, Topic, _Env, #{pool_reactor := PoolReactor, pool_core := PoolCore}) ->
6760
EnvVariables = ubidots_emqx_retainer_settings:get_settings(),

0 commit comments

Comments
 (0)