Giter Club home page Giter Club logo

cl-xmpp's Introduction

cl-xmpp

This is a Common Lisp implementation of the XMPP RFCs. Please see http://common-lisp.net/project/cl-xmpp for more information.

Example -

(require :cl-xmpp)
(defvar *connection* (xmpp:connect :hostname "jabber.org"))

Alternatively, use xmpp:connect-tls if you loaded cl-xmpp-tls. Note that for XMPP servers which do not have the same hostname as the domain-part of the user’s JID, you will have to pass that in. e.g. for Google Talk -

(defvar *connection* (xmpp:connect-tls :hostname "talk.google.com"
                                       :jid-domain-part "gmail.com"))

(xmpp:auth *connection* "username" "password" "resource")

…or pass :mechanism :sasl-plain, :digest-md5 or sasl-digest-md5 if you loaded cl-xmpp-sasl or cl-xmpp-tls.

Send someone a message

(xmpp:message *connection* "username@hostname" "what's going on?")

Then sit back and watch the messages roll in…

(xmpp:receive-stanza-loop *connection*)
<MESSAGE from=username@hostname to=me@myserver>
[....]

…or use xmpp:receive-stanza if you want just one stanza (note it will still block until you have received a complete stanza)

That’s it. Interrupt the loop to issue other commands, e.g.

(xmpp:get-roster *connection*)

…or any of the other ones you may find by looking through cl-xmpp.lisp and package.lisp to see which ones are exported.

If you wish to handle the incoming messages or other objects simply specify an xmpp:handle method for the objects you are interested in or (defmethod xmpp:handle (connection object) ...) to get them all. Or alternatively specify :dom-repr t to receive-stanza-loop to get DOM-ish objects.

For example, if you wanted to create an annoying reply bot -

(defmethod xmpp:handle ((connection xmpp:connection) (message xmpp:message))
  (xmpp:message connection (xmpp:from message)
                (format nil "reply to: ~a" (xmpp:message object))))

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.