(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
jidprocedureConstruct a jid struct.
jid?procedureTest if a value is a jid struct.
jid-localprocedureGet the local field of a jid struct.
jid-domainprocedureGet the domain field of a jid struct.
jid-resourceprocedureGet the resource field of a jid struct.
parse-jidprocedureParse 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->stringprocedureConvert a jid record to its string representation.
(jid->string (parse-jid "user@example.com/bot"))
; => "user@example.com/bot"jid-bareprocedureReturn 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-stanza-idprocedureGenerate a unique stanza ID.
Uses a counter combined with random bytes for uniqueness.
xmpp-messagevariableConstruct an XMPP message stanza as SXML.
(xmpp-message to: "user@ex.com" body: "Hello")
; => (message (@ (to "user@ex.com") (id "s1-...")) (body "Hello"))xmpp-presencevariableConstruct an XMPP presence stanza as SXML.
(xmpp-presence show: "away" status: "Be right back")xmpp-iqvariableConstruct an XMPP IQ stanza as SXML.
(xmpp-iq type: "get" to: "example.com"
children: (list '(query (@ (xmlns "jabber:iq:roster")))))stanza-typeprocedureGet the type of a stanza (message, presence, iq) as a symbol.
stanza-attrprocedureGet an attribute value from a stanza.
(stanza-attr msg 'to) ; => "user@example.com"stanza-toprocedureGet the 'to' attribute of a stanza.
stanza-fromprocedureGet the 'from' attribute of a stanza.
stanza-idprocedureGet the 'id' attribute of a stanza.
message-bodyprocedureGet the body text from a message stanza.
(message-body '(message (@ (to "a@b")) (body "Hello")))
; => "Hello"stanza-childprocedureFind the first child element with the given tag name.
(stanza-child msg 'body) ; => (body "Hello")stanza-childrenprocedureFind all child elements with the given tag name.
sxml-textprocedureExtract text content from an SXML element.
Returns the concatenation of all string children, or #f if none.
stanza->xmlprocedureConvert 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>"