XMPP
A module for using the Jabber/XMPP protocol.
1 Protocol Support
A minimal subset of the XMPP protocols are supported, but not much beyond sending and receiving messages and presence updates. This module should eventually implement XMPP-Core and XMPP-IM to conform with RFCs 3920 and 3921. Currently, the default connection uses ’old style’ SSL, which is deprecated and may cause problems with some servers. Progress toward supporting the full protocol is documented in the file ’xmpp.ss’
2 Session
It is necessary to establish a session with a Jabber server before sending any messages or presence updates. This can be done manually, or with the help of with-xmpp-session.
(with-xmpp-seesion [jid jid?] [password string?] body) |
Establishes an XMPP session using the id jid and password pass and evaluates the forms in body in the session’s scope.
3 Sending
Once a session is established, the ’send’ function can be used to send messages, presence updates or queries.
4 Messages
To send a message containing text to a user with the jid of to.
(with-xmpp-session jid pass |
(send (message to text))) |
5 Presence
(with-xmpp-session jid pass |
(send (presence))) |
(with-xmpp-session jid pass |
(send (presence #:status "Available"))) |
6 Response Handling
(with-xmpp-session jid pass |
(set-xmpp-handler 'message print-message)) |
7 Example Chat Client
(define (read-input prompt) |
(display prompt) |
(read-line (current-input-port))) |
(define (chat) |
(let ((jid (read-input "jid: ")) |
(pass (read-input "password: ")) |
(to (read-input "chat with: "))) |
(with-xmpp-session |
jid pass |
(set-xmpp-handler 'message print-message) |
(let loop () |
(let ((msg (read-line (current-input-port)))) |
(send (message to msg)) |
(loop)))))) |
and chat away...