XMPP-FTW


XMPP For The Web World?

The goal of XMPP-FTW is to make XMPP really simple to use for (web) developers

  • Use a (web)socket
  • No client side library
  • Common sense
  • No hand-holding
  • Good documentation
  • Use events to fill in the 'gaps'

How?

Technology


Written in nodejs

Proxy between XMPP server + browser

Doesn't mandate a transport

  • Browser == websocket
  • Powered by Primus


Acts as an XMPP client (using `node-xmpp`)

Can be run in the browser too

Modules...


  • xmpp-ftw
  • xmpp-ftw-demo
  • xmpp-ftw-avatar
  • xmpp-ftw-buddycloud
  • xmpp-ftw-disco
  • xmpp-ftw-item-parser
  • xmpp-ftw-muc
  • xmpp-ftw-pubsub
  • xmpp-ftw-register
  • xmpp-ftw-superfeedr
  • xmpp-ftw-search
  • xmpp-ftw-wtf
  • xmpp-ftw-rpc
  • xmpp-ftw-fanout
  • ...with more to come...

Code

Getting connected



            var socket = new Primus('127.0.0.14000')
    
            socket.on('online', function() {
    
                console.log('i haz websocket')
    
                socket.emit('xmpp.login', credentials)
    
                socket.on('xmpp.connection', function() {
    
                    // Now we can do all the things!
    
                })
            })
    
            

Send/Receive messages



        socket.emit(
            'xmpp.chat.message',
            {
                "to": "other@evilprofessor.co.uk",
             /* "content": "Hello world", */
             /* "format": "plain", */
             /* "state": "composing" */
            }
        )

        socket.on('xmpp.chat.message', function(data) {
            console.log(data)
        })

        

Information Queries (IQs)


(Payloads where a response will be received)



        socket.emit(
            'xmpp.area.specific',
            {
                "your": "payload"
            }, 
            function(error, data) { console.log(error, data) }
        )
        

Apply standard key names and formats across XMPP messages for convenience and familiarity

Feature discovery



        socket.emit(
            'xmpp.discover.info',
            {
                "of": "evilprofessor.co.uk"
            }, 
            function(error, features) { 
                console.log(error, features)
            }
        )
        

Lets PubSub!


Head over to 127.0.0.14000/demo

Login


xmpp.login


            {
                "jid": "<user>@evilprofessor.co.uk",
                "password": "password",
                "register": true,
                "host": "localhost"
            }
            

Publish to a node


xmpp.pubsub.publish


            {
                "to": "pubsub.evilprofessor.co.uk",
                "node": "xmpp-ftw updates",
                "content": "<your name in lights?>"
            }
            

Retrieve items


xmpp.pubsub.retrieve


            {
                "to": "pubsub.evilprofessor.co.uk",
                "node": "xmpp-ftw updates"
            }
            

Hint: Ctrl/Cmd + Click to enlarge results

Presence


Tell the server we're here & listening...


xmpp.presence


            {}
            

Subscribe and get push updates!


xmpp.pubsub.subscribe


            {
                "to": "pubsub.evilprofessor.co.uk",
                "node": "xmpp-ftw updates"
            }
            

Items are now received via the xmpp.pubsub.push.item event

What was written?


...and what did we just do?

...a web-app without a backend?

MOAR!



        npm i xmpp-ftw-demo
        npm start
        open http://localhost:3000
        

...or...


https://xmpp-ftw.jit.su



Hosted for free by nodejitsu under the open source scheme. Please show them some ❤