jid v0.1.4 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(%JID{user: "romeo", server: "montague.lit", resource: "chamber"})
"romeo@montague.lit/chamber"
iex> to_string(%JID{user: "romeo", server: "montague.lit"})
"romeo@montague.lit"
iex> to_string(%JID{server: "montague.lit"})
"montague.lit"
Link to this section Summary
Link to this section Types
Link to this section Functions
bare(jid)
Returns a binary JID without a resource.
Examples
iex> JID.bare(%JID{user: "romeo", server: "montague.lit", resource: "chamber"})
"romeo@montague.lit"
iex> JID.bare("romeo@montague.lit/chamber")
"romeo@montague.lit"
parse(string)
Parses a binary string JID into a JID struct.
Examples
iex> JID.parse("romeo@montague.lit/chamber")
%JID{user: "romeo", server: "montague.lit", resource: "chamber", full: "romeo@montague.lit/chamber"}
iex> JID.parse("romeo@montague.lit")
%JID{user: "romeo", server: "montague.lit", resource: "", full: "romeo@montague.lit"}