sigildocs

(sigil xmpp)

(sigil xmpp) - XMPP Client Library

Provides a complete XMPP client with STARTTLS, SASL authentication, stanza handling, roster, presence, MUC, and cooperative I/O.

Exports

Install roster, presence, and MUC feature handlers on a connection.

Call this after creating a connection to enable automatic roster push handling, presence tracking, and MUC occupant tracking.

(define conn (make-xmpp-connection ...))
(xmpp-install-features conn)
(xmpp-connect conn)
jidprocedure

Construct a jid struct.

Re-exported from (sigil xmpp stanza)

jid?procedure

Test if a value is a jid struct.

Re-exported from (sigil xmpp stanza)

jid-localprocedure

Get the local field of a jid struct.

Re-exported from (sigil xmpp stanza)

jid-domainprocedure

Get the domain field of a jid struct.

Re-exported from (sigil xmpp stanza)

jid-resourceprocedure

Get the resource field of a jid struct.

Re-exported from (sigil xmpp stanza)

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">

Re-exported from (sigil xmpp stanza)

jid->stringprocedure

Convert a jid record to its string representation.

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

Re-exported from (sigil xmpp stanza)

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"

Re-exported from (sigil xmpp stanza)

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"))

Re-exported from (sigil xmpp stanza)

Construct an XMPP presence stanza as SXML.

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

Re-exported from (sigil xmpp stanza)

xmpp-iqvariable

Construct an XMPP IQ stanza as SXML.

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

Re-exported from (sigil xmpp stanza)

stanza-typeprocedure

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

Re-exported from (sigil xmpp stanza)

stanza-attrprocedure

Get an attribute value from a stanza.

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

Re-exported from (sigil xmpp stanza)

stanza-toprocedure

Get the 'to' attribute of a stanza.

Re-exported from (sigil xmpp stanza)

stanza-fromprocedure

Get the 'from' attribute of a stanza.

Re-exported from (sigil xmpp stanza)

stanza-idprocedure

Get the 'id' attribute of a stanza.

Re-exported from (sigil xmpp stanza)

message-bodyprocedure

Get the body text from a message stanza.

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

Re-exported from (sigil xmpp stanza)

stanza-childprocedure

Find the first child element with the given tag name.

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

Re-exported from (sigil xmpp stanza)

Find all child elements with the given tag name.

Re-exported from (sigil xmpp stanza)

sxml-textprocedure

Extract text content from an SXML element.

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

Re-exported from (sigil xmpp stanza)

Generate a unique stanza ID.

Uses a counter combined with random bytes for uniqueness.

Re-exported from (sigil xmpp stanza)

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>"

Re-exported from (sigil xmpp stanza)

Select the best SASL mechanism from a list of server-offered mechanisms.

Returns a symbol: 'scram-sha-1, 'plain, or #f if none supported.

Re-exported from (sigil xmpp sasl)

Create a new XMPP connection (does not connect yet).

(make-xmpp-connection
  server: "example.com"
  jid: "bot@example.com"
  password: "secret"
  resource: "bot")

Re-exported from (sigil xmpp connection)

Test if a value is a xmpp-connection struct.

Re-exported from (sigil xmpp connection)

Get the server field of a xmpp-connection struct.

Re-exported from (sigil xmpp connection)

Get the port field of a xmpp-connection struct.

Re-exported from (sigil xmpp connection)

Get the jid field of a xmpp-connection struct.

Re-exported from (sigil xmpp connection)

Get the state field of a xmpp-connection struct.

Re-exported from (sigil xmpp connection)

Get the bound-jid field of a xmpp-connection struct.

Re-exported from (sigil xmpp connection)

xmpp-connectprocedure

Connect to the XMPP server.

Performs the full XMPP connection sequence: TCP connect -> stream open -> STARTTLS -> SASL auth -> bind

Returns #t on success, #f on failure.

Re-exported from (sigil xmpp connection)

Disconnect from the XMPP server.

Re-exported from (sigil xmpp connection)

Check if connection is in connected state.

Re-exported from (sigil xmpp connection)

Register a handler for all incoming stanzas.

Re-exported from (sigil xmpp connection)

xmpp-onprocedure

Register a handler for a specific event type.

Event types: 'message, 'presence, 'iq, 'connected, 'disconnected, 'error

Re-exported from (sigil xmpp connection)

xmpp-send-iqprocedure

Send an IQ stanza and register a callback for the response.

The callback receives the response stanza.

(xmpp-send-iq conn
  (xmpp-iq type: "get" children: '((query (@ (xmlns "jabber:iq:roster")))))
  (lambda (response) (display "Got roster\n")))

Re-exported from (sigil xmpp connection)

xmpp-channelprocedure

Get a channel for receiving events of a given type.

Creates a broadcast subscription. Use with channel-receive or for-channel.

(let ((msgs (xmpp-channel conn 'message)))
  (for-channel msgs
    (lambda (stanza)
      (display (message-body stanza)))))

Re-exported from (sigil xmpp connection)

xmpp-sendprocedure

Send a stanza (SXML) to the server.

(xmpp-send conn (xmpp-message to: "user@ex.com" body: "Hi"))

Re-exported from (sigil xmpp connection)

xmpp-send-rawprocedure

Send raw XML string to the server.

Re-exported from (sigil xmpp connection)

Process available input from the XMPP connection.

Returns #t if connection is alive, #f if disconnected.

Re-exported from (sigil xmpp connection)

xmpp-runprocedure

Run the XMPP connection event loop.

Processes stanzas until disconnected. When running inside a with-async context, cooperates with other tasks via await-readable. Otherwise blocks in a traditional event loop.

Re-exported from (sigil xmpp connection)

xmpp-tickprocedure

Process one tick of the XMPP connection (non-blocking).

Returns #t if connection is alive, #f if disconnected.

Re-exported from (sigil xmpp connection)

Send initial presence to indicate availability.

Re-exported from (sigil xmpp connection)

roster-itemprocedure

Construct a roster-item struct.

Re-exported from (sigil xmpp roster)

roster-item?procedure

Test if a value is a roster-item struct.

Re-exported from (sigil xmpp roster)

Get the jid field of a roster-item struct.

Re-exported from (sigil xmpp roster)

Get the name field of a roster-item struct.

Re-exported from (sigil xmpp roster)

Get the subscription field of a roster-item struct.

Re-exported from (sigil xmpp roster)

Get the groups field of a roster-item struct.

Re-exported from (sigil xmpp roster)

Get the ask field of a roster-item struct.

Re-exported from (sigil xmpp roster)

Request the roster from the server.

Calls callback with a list of roster-item records.

(xmpp-request-roster conn
  (lambda (items)
    (for-each (lambda (item)
                (display (roster-item-jid item)))
              items)))

Re-exported from (sigil xmpp roster)

xmpp-rosterprocedure

Get the cached roster as a list of roster-items.

Returns #f if the roster hasn't been fetched yet.

Re-exported from (sigil xmpp roster)

Look up a specific contact in the cached roster.

Re-exported from (sigil xmpp roster)

Add or update a contact in the roster.

(xmpp-roster-add conn "friend@example.com" name: "Friend")

Re-exported from (sigil xmpp roster)

Remove a contact from the roster.

Re-exported from (sigil xmpp roster)

Send a subscription request to a JID.

Re-exported from (sigil xmpp roster)

Accept a subscription request from a JID.

Re-exported from (sigil xmpp roster)

Deny a subscription request from a JID.

Re-exported from (sigil xmpp roster)

Unsubscribe from a JID's presence.

Re-exported from (sigil xmpp roster)

presence-infoprocedure

Construct a presence-info struct.

Re-exported from (sigil xmpp presence)

Test if a value is a presence-info struct.

Re-exported from (sigil xmpp presence)

Get the jid field of a presence-info struct.

Re-exported from (sigil xmpp presence)

Get the show field of a presence-info struct.

Re-exported from (sigil xmpp presence)

Get the status field of a presence-info struct.

Re-exported from (sigil xmpp presence)

Get the priority field of a presence-info struct.

Re-exported from (sigil xmpp presence)

Set own presence status.

(xmpp-set-status conn show: "away" status: "Be right back")

Re-exported from (sigil xmpp presence)

Go offline (send unavailable presence and disconnect).

Re-exported from (sigil xmpp presence)

Get the cached presence info for a JID.

Returns a presence-info record or #f.

Re-exported from (sigil xmpp presence)

Get all available resources for a bare JID.

Returns a list of full JID strings that are currently available.

Re-exported from (sigil xmpp presence)

muc-roomprocedure

Construct a muc-room struct.

Re-exported from (sigil xmpp muc)

muc-room?procedure

Test if a value is a muc-room struct.

Re-exported from (sigil xmpp muc)

muc-room-jidprocedure

Get the jid field of a muc-room struct.

Re-exported from (sigil xmpp muc)

muc-room-nickprocedure

Get the nick field of a muc-room struct.

Re-exported from (sigil xmpp muc)

Get the subject field of a muc-room struct.

Re-exported from (sigil xmpp muc)

Get the occupants field of a muc-room struct.

Re-exported from (sigil xmpp muc)

Get the joined? field of a muc-room struct.

Re-exported from (sigil xmpp muc)

muc-occupantprocedure

Construct a muc-occupant struct.

Re-exported from (sigil xmpp muc)

muc-occupant?procedure

Test if a value is a muc-occupant struct.

Re-exported from (sigil xmpp muc)

Get the nick field of a muc-occupant struct.

Re-exported from (sigil xmpp muc)

Get the jid field of a muc-occupant struct.

Re-exported from (sigil xmpp muc)

Get the affiliation field of a muc-occupant struct.

Re-exported from (sigil xmpp muc)

Get the role field of a muc-occupant struct.

Re-exported from (sigil xmpp muc)

xmpp-muc-joinprocedure

Join a MUC room.

(xmpp-muc-join conn "room@conference.example.com" "mynick")

Re-exported from (sigil xmpp muc)

Leave a MUC room.

Re-exported from (sigil xmpp muc)

Send a message to a MUC room.

(xmpp-muc-message conn "room@conference.example.com" "Hello room!")

Re-exported from (sigil xmpp muc)

Send a private message to a MUC occupant.

Re-exported from (sigil xmpp muc)

Set the subject of a MUC room.

Re-exported from (sigil xmpp muc)

Get the occupants of a MUC room.

Returns a list of muc-occupant records, or '() if not in the room.

Re-exported from (sigil xmpp muc)

Kick an occupant from a MUC room (requires moderator role).

Re-exported from (sigil xmpp muc)

Send a mediated invitation to a user.

Re-exported from (sigil xmpp muc)