Hedwig.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).

Summary

Functions

Returns a binary JID without a resource

Parses a binary string JID into a JID struct

Types

t :: %Hedwig.JID{resource: term, server: term, user: term}

Functions

bare(jid)

Specs

bare(jid :: binary | Hedwig.JID.t) :: binary

Returns a binary JID without a resource.

Examples

iex> Hedwig.JID.bare(%Hedwig.JID{user: "romeo", server: "capulet.lit", resource: "chamber"})
"romeo@capulet.lit"

iex> Hedwig.JID.bare("romeo@capulet.lit/chamber")
"romeo@capulet.lit"
parse(string)

Specs

parse(jid :: binary) :: Hedwig.JID.t

Parses a binary string JID into a JID struct.

Examples

iex> Hedwig.JID.parse("romeo@capulet.lit/chamber")
%Hedwig.JID{user: "romeo", server: "capulet.lit", resource: "chamber"}

iex> Hedwig.JID.parse("romeo@capulet.lit")
%Hedwig.JID{user: "romeo", server: "capulet.lit", resource: ""}