4
4
% % no need for this include if we call emqx_message:to_map/1 to convert it to a map
5
5
-include_lib (" emqx/include/emqx.hrl" ).
6
6
-include_lib (" emqx/include/emqx_hooks.hrl" ).
7
- -include_lib (" hocon/include/hoconsc.hrl" ).
8
7
% % for logging
9
8
-include_lib (" emqx/include/logger.hrl" ).
10
9
15
14
% % Client Lifecycle Hooks
16
15
-export ([on_client_subscribe /4 , on_client_unsubscribe /4 ]).
17
16
% % Session Lifecycle Hooks
18
- -export ([on_session_subscribed /5 ]).
17
+ -export ([on_session_subscribed /4 ]).
19
18
% % Message Pubsub Hooks
20
19
-export ([on_message_delivered /3 ]).
21
20
22
21
% % Called when the plugin application start
23
22
load (Env ) ->
24
23
ubidots_emqx_retainer_ecpool :start_pools (? POOL_REACTOR , ? POOL_CORE , Env ),
25
- Config = #{pool_reactor => ? POOL_REACTOR , pool_core => ? POOL_CORE },
26
24
hook ('client.subscribe' , {? MODULE , on_client_subscribe , [Env ]}),
27
25
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 ]}),
29
27
hook ('message.delivered' , {? MODULE , on_message_delivered , [Env ]}).
30
28
31
29
% %--------------------------------------------------------------------
@@ -52,16 +50,11 @@ on_client_unsubscribe(#{username := UserName}, _Properties, TopicFilters, _Env)
52
50
% % Session Lifecycle Hooks
53
51
% %--------------------------------------------------------------------
54
52
55
- on_session_subscribed (_ , _ , #{share := ShareName }, _Env , _Config )
56
- when ShareName =/= undefined ->
53
+ on_session_subscribed (_ , _ , #{share := ShareName }, _Env ) when ShareName =/= undefined ->
57
54
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 ]).
65
58
66
59
dispatch (Pid , Topic , _Env , #{pool_reactor := PoolReactor , pool_core := PoolCore }) ->
67
60
EnvVariables = ubidots_emqx_retainer_settings :get_settings (),
0 commit comments