Romeo v0.7.0 Romeo.Stanza
Provides convenience functions for building XMPP stanzas.
Summary
Functions
Ends the XML stream
Generates a random hex string for use as an id for a stanza
Generates a presence stanza to join a MUC room
Returns a presence stanza to a given jid, of a given type
Starts an XML stream
Generates the XML to start TLS
Generates a stanza to join a pubsub node. (XEP-0060)
Converts an xml
record to an XML binary string
Functions
Ends the XML stream
Example
iex> stanza = Romeo.Stanza.end_stream
{:xmlstreamend, "stream:stream"}
iex> Romeo.Stanza.to_xml(stanza)
"</stream:stream>"
Generates a presence stanza to join a MUC room.
Options
password
- the password for a MUC room - if required.history
- used for specifying the amount of old messages to receive once joined. The value of the:history
option should be a keyword list of one of the following:maxchars
- limit the total number of characters in the history.maxstanzas
- limit the total number of messages in the history.seconds
- send only the messages received in the lastn
seconds.since
- send only the messages received since the UTC datetime specified. See http://xmpp.org/extensions/xep-0045.html#enter-managehistory for details.
Examples
iex> Romeo.Stanza.join("lobby@muc.localhost", "hedwigbot")
{:xmlel, "presence", [{"to", "lobby@muc.localhost/hedwigbot"}],
[{:xmlel, "x", [{"xmlns", "http://jabber.org/protocol/muc"}],
[{:xmlel, "history", [{"maxstanzas", "0"}], []}]}]}
Starts an XML stream.
Example
iex> stanza = Romeo.Stanza.start_stream("im.capulet.lit")
{:xmlstreamstart, "stream:stream",
[{"to", "im.capulet.lit"}, {"version", "1.0"}, {"xml:lang", "en"},
{"xmlns", "jabber:client"},
{"xmlns:stream", "http://etherx.jabber.org/streams"}]}
iex> Romeo.Stanza.to_xml(stanza)
"<stream:stream to='im.capulet.lit' version='1.0' xml:lang='en' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'>"