sigildocs

(sigil xmpp stanza)

(sigil xmpp stanza) - XMPP Stanza Construction and JID Handling

Provides JID parsing, stanza constructors, stanza inspection, and XML serialization for XMPP protocol elements.

Exports

jidprocedure

Construct a jid struct.

jid?procedure

Test if a value is a jid struct.

jid-localprocedure

Get the local field of a jid struct.

jid-domainprocedure

Get the domain field of a jid struct.

jid-resourceprocedure

Get the resource field of a jid struct.

parse-jidprocedure

Parse a JID string into a jid record.

Handles formats: "local@domain/resource", "local@domain", "domain/resource", and bare "domain".

(parse-jid "user@example.com/bot")
; => #<jid local: "user" domain: "example.com" resource: "bot">
jid->stringprocedure

Convert a jid record to its string representation.

(jid->string (parse-jid "user@example.com/bot"))
; => "user@example.com/bot"
jid-bareprocedure

Return the bare JID (without resource) as a string.

(jid-bare "user@example.com/bot")  ; => "user@example.com"
(jid-bare (parse-jid "user@example.com/bot"))  ; => "user@example.com"

Generate a unique stanza ID.

Uses a counter combined with random bytes for uniqueness.

xmpp-messagevariable

Construct an XMPP message stanza as SXML.

(xmpp-message to: "user@ex.com" body: "Hello")
; => (message (@ (to "user@ex.com") (id "s1-...")) (body "Hello"))

Construct an XMPP presence stanza as SXML.

(xmpp-presence show: "away" status: "Be right back")
xmpp-iqvariable

Construct an XMPP IQ stanza as SXML.

(xmpp-iq type: "get" to: "example.com"
         children: (list '(query (@ (xmlns "jabber:iq:roster")))))
stanza-typeprocedure

Get the type of a stanza (message, presence, iq) as a symbol.

stanza-attrprocedure

Get an attribute value from a stanza.

(stanza-attr msg 'to)  ; => "user@example.com"
stanza-toprocedure

Get the 'to' attribute of a stanza.

stanza-fromprocedure

Get the 'from' attribute of a stanza.

stanza-idprocedure

Get the 'id' attribute of a stanza.

message-bodyprocedure

Get the body text from a message stanza.

(message-body '(message (@ (to "a@b")) (body "Hello")))
; => "Hello"
stanza-childprocedure

Find the first child element with the given tag name.

(stanza-child msg 'body)  ; => (body "Hello")

Find all child elements with the given tag name.

sxml-textprocedure

Extract text content from an SXML element.

Returns the concatenation of all string children, or #f if none.

stanza->xmlprocedure

Convert a stanza (SXML) to an XML string.

(stanza->xml (xmpp-message to: "user@ex.com" body: "Hi"))
; => "<message to=\"user@ex.com\" ...><body>Hi</body></message>"