Romeo v0.5.0 Romeo.JID
Jabber Identifiers (JIDs) uniquely identify individual entities in an XMPP network.
A JID often resembles an email address with a user@host form, but there’s a bit more to it. JIDs consist of three main parts:
A JID can be composed of a local part, a server part, and a resource part. The server part is mandatory for all JIDs, and can even stand alone (e.g., as the address for a server).
The combination of a local (user) part and a server is called a “bare JID”, and it is used to identitfy a particular account on a server.
A JID that includes a resource is called a “full JID”, and it is used to identify a particular client connection (i.e., a specific connection for the associated “bare JID” account).
This module implements the to_string/1
for the String.Chars
protocol for
returning a binary string from the JID
struct.
Returns a string representation from a JID struct.
Examples
iex> to_string(%Romeo.JID{user: "romeo", server: "montague.lit", resource: "chamber"})
"romeo@montague.lit/chamber"
iex> to_string(%Romeo.JID{user: "romeo", server: "montague.lit"})
"romeo@montague.lit"
iex> to_string(%Romeo.JID{server: "montague.lit"})
"montague.lit"
Summary
Types
t :: %Romeo.JID{full: term, resource: term, server: term, user: term}
Functions
Specs
bare(jid :: binary | Romeo.JID.t) :: binary
Returns a binary JID without a resource.
Examples
iex> Romeo.JID.bare(%Romeo.JID{user: "romeo", server: "montague.lit", resource: "chamber"})
"romeo@montague.lit"
iex> Romeo.JID.bare("romeo@montague.lit/chamber")
"romeo@montague.lit"
Specs
parse(jid :: binary) :: Romeo.JID.t
Parses a binary string JID into a JID struct.
Examples
iex> Romeo.JID.parse("romeo@montague.lit/chamber")
%Romeo.JID{user: "romeo", server: "montague.lit", resource: "chamber", full: "romeo@montague.lit/chamber"}
iex> Romeo.JID.parse("romeo@montague.lit")
%Romeo.JID{user: "romeo", server: "montague.lit", resource: "", full: "romeo@montague.lit"}