Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/helpers/amoc_xmpp.erl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
#{name => legacy_tls, description => "use legacy tls connection",
default_value => false, verification => ?V(boolean)},
#{name => connection_attempts, default_value => 1, verification => ?V(positive_integer),
description => "number of attempts to establish xmpp connection before exiting"}]).
description => "number of attempts to establish xmpp connection before exiting"},
#{name => message_body, default_value => <<"hello">>, verification => ?V(binary),
description => "body of the message to send"}]).

%% @doc Connects and authenticates a user with the given id and additional properties.
%% If the passed proplist is empty, a default user spec created by
Expand Down
6 changes: 4 additions & 2 deletions src/helpers/amoc_xmpp_muc.erl
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ received_handler_spec() ->

-spec ttd(exml:element(), escalus_connection:metadata()) -> non_neg_integer().
ttd(Stanza, #{recv_timestamp := ReceivedTS}) ->
SentBin = exml_query:path(Stanza, [{element, <<"body">>}, cdata]),
SentBin = exml_query:path(Stanza, [{element, <<"timestamp">>}, cdata]),
ReceivedTS - binary_to_integer(SentBin).

-spec is_muc_notification(exml:element()) -> boolean().
Expand All @@ -106,7 +106,9 @@ is_muc_message(_) -> false.
-spec send_message_to_room(escalus:client(), binary()) -> ok.
send_message_to_room(Client, RoomJid) ->
Timestamp = integer_to_binary(os:system_time(microsecond)),
escalus:send(Client, escalus_stanza:groupchat_to(RoomJid, Timestamp)).
Message = #xmlel{children = Children} = escalus_stanza:groupchat_to(RoomJid, cfg(message_body)),
TimestampElement = #xmlel{name = <<"timestamp">>, children = [#xmlcdata{content = Timestamp}]},
escalus:send(Client, Message#xmlel{children = [TimestampElement | Children]}).

%%% MUC Light: Room creation

Expand Down
2 changes: 1 addition & 1 deletion src/scenarios/dynamic_domains_pm.erl
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ do(MyId, Client) ->

-spec send_stanza(escalus:client(), chat, #state{}) -> #state{}.
send_stanza(Client, chat, State = #state{neighbours = [RecipientId | Rest]}) ->
Msg = escalus_stanza:chat_to_with_id_and_timestamp(make_jid(RecipientId), <<"hello">>),
Msg = escalus_stanza:chat_to_with_id_and_timestamp(make_jid(RecipientId), cfg(message_body)),
escalus_connection:send(Client, Msg),
State#state{neighbours = Rest ++ [RecipientId]}.

Expand Down