sigildocs

(sigil xmpp connection)

(sigil xmpp connection) - XMPP Connection Lifecycle

Manages XMPP connections with STARTTLS, SASL authentication, resource binding, stanza dispatch, and cooperative I/O.

Exports

Construct a xmpp-connection struct.

Test if a value is a xmpp-connection struct.

Get the server field of a xmpp-connection struct.

Get the port field of a xmpp-connection struct.

Get the jid field of a xmpp-connection struct.

Get the password field of a xmpp-connection struct.

Get the resource field of a xmpp-connection struct.

Get the state field of a xmpp-connection struct.

Get the socket field of a xmpp-connection struct.

Get the tls-conn field of a xmpp-connection struct.

Get the reader field of a xmpp-connection struct.

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

Get the sasl-state field of a xmpp-connection struct.

Get the stanza-handlers field of a xmpp-connection struct.

Get the event-handlers field of a xmpp-connection struct.

Get the iq-callbacks field of a xmpp-connection struct.

Get the broadcasts field of a xmpp-connection struct.

Set the state field of a xmpp-connection struct.

Set the socket field of a xmpp-connection struct.

Set the tls-conn field of a xmpp-connection struct.

Set the reader field of a xmpp-connection struct.

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

Set the sasl-state field of a xmpp-connection struct.

Set the stanza-handlers field of a xmpp-connection struct.

Set the event-handlers field of a xmpp-connection struct.

Set the iq-callbacks field of a xmpp-connection struct.

Set the broadcasts field of a xmpp-connection struct.

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

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

Check if connection is in connected state.

Register a handler for all incoming stanzas.

xmpp-onprocedure

Register a handler for a specific event type.

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

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)))))
xmpp-sendprocedure

Send a stanza (SXML) to the server.

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

Send raw XML string to the server.

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

Send initial presence to indicate availability.

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.

Disconnect from the XMPP server.

Process available input from the XMPP connection.

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

xmpp-tickprocedure

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

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

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.