Authors: Jean-Sébastien Pédron (js.pedron@meetic-corp.com).
The module exmpp_stream provides utilities to open and close an XMPP stream, negotiate features and handle stream errors.
exmpp_client_stream
and exmpp_server_stream
should be
prefered to exmpp_stream because they'll set some defaults values for
the caller.
It covers these basic functions:
A common use case is illustrated in table 1.
Client-side | Server-side |
---|---|
The client call Opening = exmpp_stream:opening( "jabber.example.com", ?NS_JABBER_CLIENT, "1.0" After serialization, this produces this XML message: <stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" to="jabber.example.org" version="1.0"> |
|
If the server accepts the client stream opening, it'll call: Opening_Reply = exmpp_stream:opening_reply( Opening, random After serialization, this produces this XML message: <stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" version="1.0" from="jabber.example.org" id="stream-396429316">
Note that |
|
At the end of the communication, the client close its stream: Client_Closing = exmpp_stream:closing(). After serialization, this produces this XML message: </stream:stream> |
|
The server do the same: Server_Closing = exmpp_stream:closing(Client_Closing). After serialization, this produces this XML message: </stream:stream> The server may use the same function clause than the client but here, it gives the client closing to the function. This is to be sure to use the same XML prefix. |
closing/0 | Make a </stream> closing tag. |
closing/1 | Make a </stream> closing tag for the given Opening tag. |
error/1 | Make a standard <stream:error> element based on the given
Condition . |
error/2 | |
features/1 | Make the features annoucement element. |
get_condition/1 | Return the child element name corresponding to the stanza error condition. |
get_default_ns/1 | Return the default namespace. |
get_id/1 | Return the stream ID. |
get_initiating_entity/1 | Return the initiating entity hostname. |
get_lang/1 | Return the language of the stream. |
get_receiving_entity/1 | Return the receiving entity hostname. |
get_text/1 | Return the text that describes the error. |
get_version/1 | Return the version of the stream. |
is_error/1 | Tell if this element is a stream error. |
opening/3 | Make a <stream> opening tag. |
opening/4 | Make a <stream> opening tag. |
opening_reply/2 | Make a <stream> opening reply tag for the given Opening tag. |
opening_reply/3 | Make a <stream> opening reply tag for the given Opening tag. |
opening_reply/4 | Make a <stream> opening reply tag. |
opening_reply/5 | Make a <stream> opening reply tag. |
parse_version/1 | Parse the stream version in String . |
serialize_version/1 | Make a binary() for the version attribute of a stream element. |
set_default_ns/2 | Set the default namespace. |
set_dialback_support/1 | Declare server diablack support. |
set_id/2 | Set the stream ID. |
set_initiating_entity/2 | Set the initiating entity in the from attribute. |
set_lang/2 | Set the default language. |
set_receiving_entity/2 | Set the receiving entity in the to attribute. |
set_version/2 | Set the protocol version. |
to_binary/1 | Serialize a stream opening/closing. |
to_iolist/1 | Serialize a stream opening/closing. |
to_list/1 | Serialize a stream opening/closing. |
closing() -> Closing
Make a </stream>
closing tag.
closing(Xmlel::Opening) -> Closing
Make a </stream>
closing tag for the given Opening
tag.
error(Condition) -> Stream_Error
Make a standard <stream:error>
element based on the given
Condition
.
error(Condition, X2) -> any()
features(Features) -> Features_Announcement
Make the features annoucement element.
get_condition(Xmlel::Stream_Error) -> Condition | undefined
Return the child element name corresponding to the stanza error condition.
get_default_ns(Xmlel::Opening) -> Default_NS | undefined
Return the default namespace.
XMPP-IM definesjabber:client
and jabber:server
.
get_id(Opening) -> ID | undefined
Return the stream ID.
get_initiating_entity(Opening) -> Hostname | undefined
Return the initiating entity hostname.
get_lang(Opening) -> Lang | undefined
Return the language of the stream.
get_receiving_entity(Opening) -> Hostname | undefined
Return the receiving entity hostname.
get_text(Xmlel::Stream_Error) -> Text | undefined
Return the text that describes the error.
get_version(Opening) -> Version
Return the version of the stream.
is_error(Xmlel::XML_El) -> bool()
Tell if this element is a stream error.
opening(To, Default_NS, Version) -> Opening
Make a <stream>
opening tag.
See also: opening/4.
opening(To, Default_NS, Version, Lang) -> Opening
Make a <stream>
opening tag.
opening_reply/1
).
opening_reply(Xmlel::Opening, ID) -> Opening_Reply
Make a <stream>
opening reply tag for the given Opening
tag.
This element is supposed to be sent by the receiving entity in reply
to the initiating entity (for the other way around, see opening/1
).
ID
is random
, one will be generated automatically.
opening_reply(Xmlel::Opening, ID, Lang) -> Opening_Reply
Make a <stream>
opening reply tag for the given Opening
tag.
This element is supposed to be sent by the receiving entity in reply
to the initiating entity (for the other way around, see opening/1
).
ID
is random
, one will be generated automatically.
opening_reply(From, Default_NS, Version, ID) -> Opening_Reply
Make a <stream>
opening reply tag.
See also: opening_reply/5.
opening_reply(From, Default_NS, Version, ID, Lang) -> Opening_Reply
Make a <stream>
opening reply tag.
This element is supposed to be sent by the receiving entity in reply
to the initiating entity (for the other way around, see opening/1
).
ID
is random
, one will be generated automatically.
parse_version(String) -> Version
Parse the stream version in String
.
serialize_version(X1::Version) -> Binary
Make a binary() for the version
attribute of a stream element.
set_default_ns(Xmlel::Opening, NS) -> New_Opening
Set the default namespace.
XMPP-IM definesjabber:client
and jabber:server
.
set_dialback_support(Opening) -> New_Opening
Declare server diablack support.
set_id(Xmlel::Opening, ID) -> New_Opening
Set the stream ID.
set_initiating_entity(Xmlel::Opening, Hostname) -> New_Opening
Set the initiating entity in the from
attribute.
set_lang(Xmlel::Opening, Lang) -> New_Opening
Set the default language.
set_receiving_entity(Xmlel::Opening, Hostname) -> New_Opening
Set the receiving entity in the to
attribute.
set_version(Xmlel::Opening, Version) -> New_Opening
Set the protocol version.
to_binary(El) -> XML_Text
Serialize a stream opening/closing.
to_iolist(El) -> XML_Text
Serialize a stream opening/closing.
to_list(El) -> XML_Text
Serialize a stream opening/closing.
Generated by EDoc, Jan 21 2011, 01:43:51.