Hedwig.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 exml
record to an XML binary string
Functions
Ends the XML stream
Example
iex> stanza = Hedwig.Stanza.end_stream
{:xmlstreamend, "stream:stream"}
iex> Hedwig.Stanza.to_xml(stanza)
"</stream:stream>"
Generates a presence stanza to join a MUC room.
Examples
iex> Hedwig.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 = Hedwig.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> Hedwig.Stanza.to_xml(stanza)
"<stream:stream xmlns:stream='http://etherx.jabber.org/streams' xmlns='jabber:client' xml:lang='en' version='1.0' to='im.capulet.lit'>"
Generates the XML to start TLS.
Example
iex> stanza = Hedwig.Stanza.start_tls
{:xmlel, "starttls", [{"xmlns", "urn:ietf:params:xml:ns:xmpp-tls"}], []}
iex> Hedwig.Stanza.to_xml(stanza)
"<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>"