2009-04-03 14:57:08 +00:00
|
|
|
#lang scribble/doc
|
|
|
|
@(require scribble/manual)
|
|
|
|
|
|
|
|
@title{XMPP}
|
|
|
|
|
|
|
|
A module for using the Jabber/XMPP protocol.
|
|
|
|
|
|
|
|
@table-of-contents[]
|
|
|
|
|
|
|
|
@section{Protocol Support}
|
|
|
|
|
2009-04-16 15:33:06 +00:00
|
|
|
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'
|
2009-04-03 14:57:08 +00:00
|
|
|
|
|
|
|
|
2009-04-16 15:33:06 +00:00
|
|
|
@section{Session}
|
2009-04-03 14:57:08 +00:00
|
|
|
|
2009-04-16 15:33:06 +00:00
|
|
|
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.
|
2009-04-03 14:57:08 +00:00
|
|
|
|
2009-04-16 15:33:06 +00:00
|
|
|
@defform[(with-xmpp-seesion [jid jid?] [password string?] body)]{
|
|
|
|
|
|
|
|
Establishes an XMPP session using the id @scheme[jid] and password
|
|
|
|
@scheme[pass] and evaluates the forms in @scheme[body] in the
|
|
|
|
session's scope.}
|
|
|
|
|
|
|
|
|
|
|
|
@section{Sending}
|
2009-04-03 14:57:08 +00:00
|
|
|
|
2009-04-16 15:33:06 +00:00
|
|
|
Once a session is established, the 'send' function can be used to send
|
|
|
|
messages, presence updates or queries.
|
2009-04-03 14:57:08 +00:00
|
|
|
|
2009-04-16 15:33:06 +00:00
|
|
|
@section{Messages}
|
2009-04-03 14:57:08 +00:00
|
|
|
|
2009-04-16 15:33:06 +00:00
|
|
|
To send a message containing @scheme[text] to a user with the
|
|
|
|
@scheme[jid] of @scheme[to].
|
|
|
|
|
2009-04-03 14:57:08 +00:00
|
|
|
@schemeblock[
|
|
|
|
(with-xmpp-session jid pass
|
|
|
|
(send (message to text)))
|
|
|
|
]
|
|
|
|
|
|
|
|
@section{Presence}
|
|
|
|
|
2009-04-16 15:33:06 +00:00
|
|
|
@schemeblock[
|
2009-04-03 14:57:08 +00:00
|
|
|
(with-xmpp-session jid pass
|
|
|
|
(send (presence)))
|
|
|
|
]
|
2009-04-16 15:33:06 +00:00
|
|
|
|
|
|
|
@schemeblock[
|
|
|
|
(with-xmpp-session jid pass
|
|
|
|
(send (presence #:status "Available")))
|
|
|
|
]
|
2009-04-03 14:57:08 +00:00
|
|
|
|
|
|
|
@section{Response Handling}
|
|
|
|
|
|
|
|
@schemeblock[
|
|
|
|
(with-xmpp-session jid pass
|
|
|
|
(set-xmpp-handler 'message print-message))
|
|
|
|
]
|
|
|
|
|
|
|
|
@section{Example Chat Client}
|
|
|
|
|
|
|
|
@schemeblock[
|
|
|
|
(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...
|