./ct_report/coverage/mod_stream_management_stanzas.COVER.html

1 -module(mod_stream_management_stanzas).
2
3 -include("jlib.hrl").
4 -include("mongoose_ns.hrl").
5
6 -export([
7 sm/0,
8 stream_mgmt_enabled/0,
9 stream_mgmt_enabled/1,
10 stream_mgmt_resumed/2,
11 stream_mgmt_failed/1,
12 stream_mgmt_failed/2,
13 stream_mgmt_ack/1,
14 stream_mgmt_request/0,
15 sm_handled_count_too_high_stanza/2
16 ]).
17
18 -spec sm() -> exml:element().
19 sm() ->
20 13666 #xmlel{name = <<"sm">>,
21 attrs = [{<<"xmlns">>, ?NS_STREAM_MGNT_3}]}.
22
23 -spec stream_mgmt_enabled() -> exml:element().
24 stream_mgmt_enabled() ->
25 19 stream_mgmt_enabled([]).
26
27 -spec stream_mgmt_enabled([exml:attr()]) -> exml:element().
28 stream_mgmt_enabled(ExtraAttrs) ->
29 48 #xmlel{name = <<"enabled">>,
30 attrs = [{<<"xmlns">>, ?NS_STREAM_MGNT_3}] ++ ExtraAttrs}.
31
32 -spec stream_mgmt_resumed(mod_stream_management:smid(), mod_stream_management:short()) ->
33 exml:element().
34 stream_mgmt_resumed(SMID, Handled) ->
35 3 #xmlel{name = <<"resumed">>,
36 attrs = [{<<"xmlns">>, ?NS_STREAM_MGNT_3},
37 {<<"previd">>, SMID},
38 {<<"h">>, integer_to_binary(Handled)}]}.
39
40 -spec stream_mgmt_failed(binary()) -> exml:element().
41 stream_mgmt_failed(Reason) ->
42 28 stream_mgmt_failed(Reason, []).
43
44 -spec stream_mgmt_failed(binary(), [exml:attr()]) -> exml:element().
45 stream_mgmt_failed(Reason, Attrs) ->
46 28 ReasonEl = #xmlel{name = Reason,
47 attrs = [{<<"xmlns">>, ?NS_STANZAS}]},
48 28 #xmlel{name = <<"failed">>,
49 attrs = [{<<"xmlns">>, ?NS_STREAM_MGNT_3} | Attrs],
50 children = [ReasonEl]}.
51
52 -spec stream_mgmt_ack(non_neg_integer()) -> exml:element().
53 stream_mgmt_ack(NIncoming) ->
54 2 #xmlel{name = <<"a">>,
55 attrs = [{<<"xmlns">>, ?NS_STREAM_MGNT_3},
56 {<<"h">>, integer_to_binary(NIncoming)}]}.
57
58 -spec stream_mgmt_request() -> exml:element().
59 stream_mgmt_request() ->
60 109 #xmlel{name = <<"r">>,
61 attrs = [{<<"xmlns">>, ?NS_STREAM_MGNT_3}]}.
62
63 -spec sm_handled_count_too_high_stanza(non_neg_integer(), non_neg_integer()) -> exml:element().
64 sm_handled_count_too_high_stanza(Handled, OldAcked) ->
65 1 #xmlel{name = <<"handled-count-too-high">>,
66 attrs = [{<<"xmlns">>, ?NS_STREAM_MGNT_3},
67 {<<"h">>, integer_to_binary(Handled)},
68 {<<"send-count">>, integer_to_binary(OldAcked)}]}.
Line Hits Source