./ct_report/coverage/gen_iq_component.COVER.html

1 -module(gen_iq_component).
2
3 %% API
4 -export([register_iq_handler/4,
5 unregister_iq_handler/3,
6 sync/1,
7 stop_iq_handler/1,
8 handle/5]).
9
10 -ignore_xref([behaviour_info/1]).
11
12 -callback register_iq_handler(Domain :: jid:server(), Namespace :: binary(),
13 IQHandler :: mongoose_iq_handler:t()) -> ok.
14
15 -callback unregister_iq_handler(Domain :: jid:server(), Namespace :: binary()) -> ok.
16
17 %% this callback can be used to ensure that all of the register/unregister requests
18 %% are done if they processed asynchronously by the component.
19 -callback sync() -> ok.
20 %%====================================================================
21 %% API
22 %%====================================================================
23 -spec register_iq_handler(Component :: module(),
24 Domain :: jid:server(),
25 Namespace :: binary(),
26 IQHandler :: mongoose_iq_handler:t()) -> ok.
27 register_iq_handler(Component, Domain, Namespace, IQHandler) ->
28 1069 Component:register_iq_handler(Domain, Namespace, IQHandler).
29
30 -spec unregister_iq_handler(Component :: module(),
31 Domain :: jid:server(),
32 Namespace :: binary()) -> ok.
33 unregister_iq_handler(Component, Domain, Namespace) ->
34 965 Component:unregister_iq_handler(Domain, Namespace).
35
36 -spec sync(Component :: module()) -> ok.
37 sync(Component) ->
38 1013 Component:sync().
39
40 -spec stop_iq_handler(IQHandler :: mongoose_iq_handler:t()) -> any().
41 stop_iq_handler(IQHandler) ->
42 %% TODO: this function is required only for correct implementation of the legacy
43 %% gen_iq_handler:remove_iq_handler/3 interface, get rid of it once old API is
44 %% removed from gen_iq_handler module.
45 965 case mongoose_iq_handler:extra(IQHandler) of
46 #{delete_on_unregister := true} ->
47 56 mongoose_iq_handler:delete(IQHandler);
48 _ ->
49 909 ok
50 end.
51
52
53 -spec handle(IQHandler :: mongoose_iq_handler:t(),
54 Acc :: mongoose_acc:t(),
55 From :: jid:jid(),
56 To :: jid:jid(),
57 IQ :: jlib:iq()) -> mongoose_acc:t().
58 handle(IQHandler, Acc, From, To, IQ) ->
59 4095 mongoose_iq_handler:process_iq(IQHandler, Acc, From, To, IQ).
Line Hits Source