Romeo v0.7.0 Romeo.Stanza

Provides convenience functions for building XMPP stanzas.

Summary

Functions

auth(mechanism)
auth(mechanism, body, additional_attrs \\ [])
base64_cdata(payload)
bind(resource)
body(data)
cdata(payload)
chat(to, body)
compress(method)
disco_info(to)
disco_items(to)
end_stream()

Ends the XML stream

Example

iex> stanza = Romeo.Stanza.end_stream
{:xmlstreamend, "stream:stream"}
iex> Romeo.Stanza.to_xml(stanza)
"</stream:stream>"
generate_body(data)
get_inband_register()
get_roster()
get_vcard(to)
groupchat(to, body)
handshake(hash)
id()

Generates a random hex string for use as an id for a stanza.

iq(type, body)
iq(to, type, body)
join(room, nickname, opts \\ [])

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 last n 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"}], []}]}]}
message(msg)
message(to, type, message)
normal(to, body)
presence()
presence(type)
presence(to, type)

Returns a presence stanza to a given jid, of a given type.

session()
set_inband_register(username, password)
set_roster_item(jid, subscription \\ "both", name \\ "", group \\ "")
start_stream(server, xmlns \\ ns_jabber_client)

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'>"
start_tls()

Generates the XML to start TLS.

Example

iex> stanza = Romeo.Stanza.start_tls
{:xmlel, "starttls", [{"xmlns", "urn:ietf:params:xml:ns:xmpp-tls"}], []}
iex> Romeo.Stanza.to_xml(stanza)
"<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>"
subscribe(to, node, jid)

Generates a stanza to join a pubsub node. (XEP-0060)

to_xml(record)

Converts an xml record to an XML binary string.

xhtml_im(data)