Copyright © (C) 2011-2012, Erlang Solutions Ltd.
This module defines the escalus_connection behaviour.
Required callback functions: connect/1, send/2, is_connected/1, reset_parser/1, use_zlib/1, upgrade_to_tls/2, set_filter_predicate/2, stop/1, kill/1, stream_start_req/1, stream_end_req/1, assert_stream_start/2, assert_stream_end/2.
client() = #client{}
filter_pred() = fun((exml_stream:element()) -> boolean()) | none
metadata() = #{recv_timestamp => integer()}
receive_options() = #{pred => stanza_pred(), safe => boolean(), with_metadata => boolean(), timeout => timeout(), name => term(), assert => {term(), list()} | term()}
stanza_handler() = fun((client(), exml_stream:element(), metadata()) -> boolean()) | fun((client(), exml_stream:element()) -> boolean())
stanza_msg() = {stanza, pid(), exml:element(), map()}
stanza_pred() = fun((exml_stream:element()) -> boolean())
step_spec() = atom() | {module(), atom()} | escalus_session:step()
t() = module()
connect/1 | |
connection_step/2 | |
get_sm_h/1 | |
get_stanza/2 | |
get_stanza/3 | |
get_stanza/4 | |
get_stanza_safe/2 | |
get_stanza_safe/3 | |
get_stanza_with_metadata/3 | |
get_stanza_with_metadata/4 | |
get_tls_last_message/1 | |
is_connected/1 | |
kill/1 | Brutally kill the connection without terminating the XMPP stream. |
maybe_forward_to_owner/5 | |
maybe_set_jid/1 | |
receive_stanza/2 | Receives incoming stanzas in a loop until the specified timeout passes. |
reset_parser/1 | |
send/2 | |
send_and_receive/3 | |
send_raw/2 | |
set_filter_predicate/2 | |
set_sm_h/2 | |
stanza_msg/2 | |
start/1 | |
start/2 | |
start_stream/1 | |
stop/1 | |
upgrade_to_tls/1 | |
use_zlib/1 | |
wait/2 | |
wait_for_close/2 | Waits at most MaxWait ms for the client to be closed. |
wait_forever/1 |
connect(Props::escalus_users:user_spec()) -> client()
connection_step(Step::step_spec(), X2::{client(), escalus_session:features()}) -> {client(), escalus_session:features()}
get_sm_h(Client::client()) -> non_neg_integer()
get_stanza(Client::client(), Name::any()) -> exml_stream:element()
get_stanza(Client::client(), Name::any(), Timeout::timeout()) -> exml_stream:element()
get_stanza(Client::client(), Name::any(), Timeout::timeout(), Pred::stanza_pred()) -> exml_stream:element()
get_stanza_safe(Client::client(), Timeout::timeout()) -> {error, timeout} | {exml_stream:element(), metadata()}
get_stanza_safe(Client::client(), Timeout::timeout(), Pred::stanza_pred()) -> {error, timeout} | {exml_stream:element(), metadata()}
get_stanza_with_metadata(Client::client(), Name::any(), Timeout::timeout()) -> {exml_stream:element(), metadata()}
get_stanza_with_metadata(Client::client(), Name::any(), Timeout::timeout(), Pred::stanza_pred()) -> {exml_stream:element(), metadata()}
get_tls_last_message(Client::client()) -> {ok, binary()} | {error, undefined_tls_message}
is_connected(Client::client()) -> boolean()
kill(Client::client()) -> ok | already_stopped
Brutally kill the connection without terminating the XMPP stream.
maybe_forward_to_owner(FilterPred::filter_pred(), State::term(), Stanzas::[exml:element()], Fun::fun(([exml:element()], term(), integer()) -> term()), Timestamp::integer()) -> term()
receive_stanza(Client::client(), Options::receive_options()) -> {exml_stream:element(), metadata()} | exml_stream:element() | {error, timeout}
Receives incoming stanzas in a loop until the specified timeout passes. Whenever a stanza is received: - If there is no 'pred' in Options OR 'pred' returns 'true', the stanza is returned. - Otherwise, the handlers specified in Client#client.props are applied one by one until one of them returns 'true'. - If any of the handlers returns 'true', the loop continues, waiting for a new stanza. - Otherwise, the stanza is returned.
Meaning of the options: - pred - receive only specific stanzas, skipping the rest and handling them with the handlers specified in the client properties - safe - return an error instead of throwing an exception when the timeout passes - with_metadata - return additional metadata with the stanza - timeout - change the default timeout value (see default_timeout/0) - name - tag the thrown timeout exception with the provided name - assert - perform an assertion on the stanza before returning itreset_parser(Client::client()) -> ok
send(Client::escalus:client(), Elem::exml_stream:element()) -> ok
send_and_receive(Client::client(), Stanza::exml_stream:element(), RecvOptions::receive_options()) -> {exml_stream:element(), metadata()} | exml_stream:element() | {error, timeout}
send_raw(Client::escalus:client(), Data::binary()) -> ok
set_filter_predicate(Client::client(), Pred::filter_pred()) -> ok
set_sm_h(Client::client(), H::non_neg_integer()) -> {ok, non_neg_integer()}
stanza_msg(Stanza::exml:element(), Metadata::map()) -> stanza_msg()
start(Props::escalus_users:user_spec()) -> {ok, client(), escalus_users:user_spec()} | {error, any()}
start(Props::escalus_users:user_spec(), Steps::[step_spec()]) -> {ok, client(), escalus_session:features()} | {error, any()}
start_stream(Client::client()) -> exml_stream:element()
stop(Client::client()) -> ok | already_stopped
upgrade_to_tls(Client::client()) -> ok
use_zlib(Client::client()) -> ok
wait(Client::client(), Timeout::timeout()) -> ok
wait_for_close(Client::client(), MaxWait::non_neg_integer()) -> boolean()
Waits at most MaxWait ms for the client to be closed. Returns true if the client was disconnected, otherwise false.
wait_forever(Client::client()) -> no_return()
Generated by EDoc