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

Latest commit

 

History

History
159 lines (104 loc) · 4.57 KB

ecomponent_con.md

File metadata and controls

159 lines (104 loc) · 4.57 KB

Module ecomponent_con

Behaviours: gen_server.

Function Index

active/1Sets the connection active.
active/2Sets the connection active.
down/1Sets the connection as down.
is_active/1Checks an ID.
passive/1Sets the connection passive.
passive/2Sets the connection passive.
resolve_id/1Resolve from group ID.
send/1Select a connection and send the stanza.
send/2Send the stanza to the specific connection.
start_link/2Starts the connection.
stop/0Stops the connection.

Function Details

active/1


active(ID::atom()) -> {active, atom()}

Sets the connection active. This function will be used for activate the connections.

active/2


active(ID::atom(), Group::atom()) -> {active, atom()}

Sets the connection active. This function will be used for activate the connections. Adds a new parameter named Group for use only this name instead of the specific (or generated) names in case of pool is used.

down/1


down(ID::atom()) -> {down, atom()}

Sets the connection as down. This function will be used to report a down from the worker connection.

is_active/1


is_active(ID::atom()) -> boolean()

Checks an ID. If the connection is available as passive or down returns true, otherwise false.

passive/1


passive(ID::atom()) -> {passive, atom()}

Sets the connection passive. This function will be used for activate as passive a connection.

passive/2


passive(ID::atom(), Group::atom()) -> {passive, atom()}

Sets the connection passive. This function will be used for activate as passive a connection. Adds a new parameter named Group for use only this name instead of the specific (or generated) names in case of pool is used.

resolve_id/1


resolve_id(ID::atom()) -> atom()

Resolve from group ID. If the ID passed as param is a group, this function returns an element inside the group in round-robin. Else, you get the same atom.

send/1


send(Info::exmpp_xml:xmlel()) -> ok

Select a connection and send the stanza.

send/2


send(Info::exmpp_xml:xmlel(), ID::atom()) -> ok

Send the stanza to the specific connection. If the connection is not available the stanza will be sent to the first available connection in the active pool. If the active pool is empty, try to send the stanza to a passive connection. And finally if this is impossible, waits a moment (2000ms) and try again.

start_link/2


start_link(JID::ecomponent:jid(), Conf::proplists:proplist()) -> {ok, pid()} | ignore | {error, {already_started, pid()}} | {error, term()}

Starts the connection. The params needed to start the connection are a JID in string format and a proplists of configurations with server or node keys available inside, and others configurations more.

stop/0


stop() -> ok

Stops the connection.