Skip to content
This repository has been archived by the owner on Jan 19, 2020. It is now read-only.

Latest commit

 

History

History
216 lines (141 loc) · 6.16 KB

ecomponent.md

File metadata and controls

216 lines (141 loc) · 6.16 KB

Module ecomponent

Behaviours: gen_server.

Function Index

gen_id/0generate an ID based on UUID v4.
prepare_id/1Ensure the string used as ID in stanza is XML valid.
send/2Send an IQ stanza.
send/3Send an IQ stanza and set the return path.
send/4Send an IQ stanza, set the return path and if there are reply or not.
send/5Send an IQ stanza with return path, reply and the server where to send.
send_message/1Send a message stanza.
send_message/2Send a message stanza.
send_presence/1Send a presence stanza.
send_presence/2Send a presence stanza.
start_link/0Starts the ecomponent main server.
stop/0Stops the ecomponent main server.
sync_send/2Send a packet and wait for the reply.
sync_send/3Send a packet and wait for the reply using a specific server to send.
sync_send/4Send a packet and wait for the reply using a specific server to send and the time to await.
unprepare_id/1Undo de action of prepare_id/1.

Function Details

gen_id/0


gen_id() -> binary()

generate an ID based on UUID v4.

prepare_id/1


prepare_id(Data::string()) -> string()

Ensure the string used as ID in stanza is XML valid.

send/2


send(Packet::term(), App::atom()) -> ok

Send an IQ stanza. The first param is a Packet in exmpp_xml format. The second param is the app where the IQ is linked, this could be an atom or a PID.

send/3


send(Packet::term(), NS::atom(), App::atom()) -> ok

Send an IQ stanza and set the return path. The same as send/2 but adds a middle param, the NS (namespace) referer to the name space of the first element inside the iq stanza.

send/4


send(Packet::term(), NS::atom(), App::atom(), Reply::boolean()) -> ok

Send an IQ stanza, set the return path and if there are reply or not. This function is the same as send/3 but adds a new param. The fourth param is for enable or disable the waiting for the reply.

send/5


send(Packet::term(), NS::atom(), App::atom(), Reply::boolean(), ServerID::atom()) -> ok

Send an IQ stanza with return path, reply and the server where to send. This function adds a new param. The fifth param is the name of the connection where the stanza should be sent.

send_message/1


send_message(Packet::term()) -> ok

Send a message stanza. The Packet should be in exmpp_xml format.

send_message/2


send_message(Packet::term(), ServerID::atom()) -> ok

Send a message stanza. The Packet should be in exmpp_xml format. This function adds the possibility to select the server for send the stanza.

send_presence/1


send_presence(Packet::term()) -> ok

Send a presence stanza. The Packet should be in exmpp_xml format.

send_presence/2


send_presence(Packet::term(), ServerID::atom()) -> ok

Send a presence stanza. The Packet should be in exmpp_xml format. This function adds the possibility to select the server for send the stanza.

start_link/0


start_link() -> {ok, Pid::pid()} | {error, Reason::any()}

Starts the ecomponent main server.

stop/0


stop() -> ok

Stops the ecomponent main server.

sync_send/2


sync_send(Packet::term(), NS::atom()) -> #params{} | {error, timeout}

Send a packet and wait for the reply. Send a packet as do send/3, but the return path is the current process for get the response. The first param is a Packet in the exmpp_xml format. The second param is the namespace (NS).

sync_send/3


sync_send(Packet::term(), NS::atom(), ServerID::atom()) -> #params{} | {error, timeout}

Send a packet and wait for the reply using a specific server to send. As in send/3, but the return path is the current process for get the response.

sync_send/4


sync_send(Packet::term(), NS::atom(), ServerID::atom(), Timeout::pos_integer()) -> #params{} | {error, tiemout}

Send a packet and wait for the reply using a specific server to send and the time to await. As in send/3, but you can specify the timeout in milliseconds.

unprepare_id/1


unprepare_id(Data::string()) -> string()

Undo de action of prepare_id/1.