SlideShare une entreprise Scribd logo
1  sur  79
Télécharger pour lire hors ligne
October 2011




Powering your website with
      realtime data



    Bert Van Hauwaert
bert@becoded.be - @tbotwit
Bert Van Hauwaert

•   Live in Belgium

•   Founder of be.coded

•   Freelance web application developer & consultant

•   ZCE 5.0

•   Working on realtime auction sites
Overview

•   The old days

•   XMPP

•   Install server

•   Configure apache

•   Libraries

•   Examples
Overview

•   The old days

•   XMPP

•   Install server

•   Configure apache

•   Libraries

•   Examples
The old days


•   <meta http-equiv=”refresh” content=”5” />

•   <script >

•   AJAX
Overview

•   The old days

•   XMPP

•   Install server

•   Configure apache

•   Libraries

•   Examples
XMPP: what


•   Extensible Messaging and Presence Protocol

•   Jabber

•   XML

•   Client - Server - Component
XMPP: stanzas


•   <presence>

•   <message>

•   <iq>
XMPP: stanzas


•   <presence>

•   <message>

•   <iq>
XMPP: stanzas


•   <presence>

•   <message>

•   <iq>
XMPP: stanzas


•   <presence>

•   <message>

•   <iq>
XMPP: addressing


•   JID (Jabber Identifier)

•   Three main parts

    •   [ node "@" ] domain [ "/" resource ]
XMPP: extensions



•   XMPP Extension Protocol - XEP

•   http://xmpp.org/xmpp-protocols/xmpp-extensions/
XMPP: advantages


•   Open

•   Decentralized

•   Secure

•   Extensible
XMPP: disadvantages



•   Statefulness

•   Overhead
XMPP: example
<stream:stream>
   <iq type="get" id="roster1">
      <query xmlns:"jabber:iq:roster" />
   </iq>

   <presence />
   <message to="attendees@zendcon.com"
      from="bert@becoded.be/speakerroom"
      type="chat">
          <body>
             I hope you will enjoy this talk
          </body>
   </message>
   <presence>
      <show>dnd</show>
      <status>Giving a talk @ ZendCon</status>
   </presence>
</stream:stream>
XMPP: example
<stream:stream>
    <iq type="get" id="roster1">
        <query xmlns:"jabber:iq:roster" />
    </iq>

    <presence />
    <message to="attendees@zendcon.com"
         from="bert@becoded.be/speakerroom"
         type="chat">
             <body>
                  I hope you will enjoy this talk
             </body>
    </message>
    <presence>
         <show>dnd</show>
         <status>Giving a talk @ ZendCon</status>
    </presence>
</stream:stream>
XMPP: example
<stream:stream>
    <iq type="get" id="roster1">
      <query xmlns:"jabber:iq:roster" />
    </iq>
    <presence />
    <message to="attendees@zendcon.com"
         from="bert@becoded.be/speakerroom"
         type="chat">
             <body>
                  I hope you will enjoy this talk
             </body>
    </message>
    <presence>
         <show>dnd</show>
         <status>Giving a talk @ ZendCon</status>
    </presence>
</stream:stream>
XMPP: example
<stream:stream>
    <iq type="get" id="roster1">
         <query xmlns:"jabber:iq:roster" />
    </iq>


    <presence />
    <message to="attendees@zendcon.com"
         from="bert@becoded.be/speakerroom"
         type="chat">
             <body>
                  I hope you will enjoy this talk
             </body>
    </message>
    <presence>
         <show>dnd</show>
         <status>Giving a talk @ ZendCon</status>
    </presence>
</stream:stream>
XMPP: example
<stream:stream>
    <iq type="get" id="roster1">
         <query xmlns:"jabber:iq:roster" />
    </iq>

    <presence />
    <message to="attendees@zendcon.com"
      from="bert@becoded.be/speakerroom"
      type="chat">
        <body>
          I hope you will enjoy this talk
        </body>
    </message>
    <presence>
         <show>dnd</show>
         <status>Giving a talk @ ZendCon</status>
    </presence>
</stream:stream>
XMPP: example
<stream:stream>
    <iq type="get" id="roster1">
         <query xmlns:"jabber:iq:roster" />
    </iq>

    <presence />
    <message to="attendees@zendcon.com"
        from="bert@becoded.be/speakerroom"
        type="chat">
             <body>
                 I hope you will enjoy this talk
             </body>
    </message>
    <presence>
      <show>dnd</show>
      <status>
        Giving a talk @ ZendCon
      </status>
    </presence>
</stream:stream>
XMPP: example
<stream:stream>
    <iq type="get" id="roster1">
         <query xmlns:"jabber:iq:roster" />
    </iq>

    <presence />
    <message to="attendees@zendcon.com"
        from="bert@becoded.be/speakerroom"
        type="chat">
             <body>
                 I hope you will enjoy this talk
             </body>
    </message>
    <presence>
        <show>dnd</show>
        <status>
             Giving a talk @ ZendCon
        </status>
    </presence>
</stream:stream>
XMPP: XEP-0060         (1)




•   PubSub (Publish / Subscribe)

•   Bandwidth / resources
XMPP: XEP-0060              (2)



<iq
  from="child@holiday.com/car"
  id="ams9nz78"
  to="pubsub.holiday.com"
  type="set">
    <pubsub xmlns="http://jabber.org/
    protocol/pubsub">
      <subscribe node="are-we-there-yet"
      jid="child@holiday.com"/>
    </pubsub>
</iq>
XMPP: XEP-0060                    (3)

<iq
  from="adult@holiday.com/car"
  id="wmn78e45a" to="pubsub.holiday.com"
  type="set">
    <pubsub xmlns="http://jabber.org/protocol/pubsub">
      <publish node="are-we-there-yet">
        <item>
          <there xmlns="http://holiday.com/there-yet"
          status="true"/>
        </item>
      </publish>
    </pubsub>
</iq>
XMPP: XEP-0060                     (4)



<message from="pubsub.holiday.com"
to="child@holiday.com">
  <event xmlns="http://jabber.org/protocol/pubsub#event">
    <items node="are-we-there-yet">
      <item id="ax78ui789q">
        <there xmlns="http://holiday.com/there-yet"
        status="true"/>
      </item>
    </items>
  </event>
</message>
XMPP: XEP-0045   (1)




•   MUC / Multi-User Chat

•   “Multiplier”
XMPP: XEP-0045             (2)




<presence
  from="user@domain.com/resource"
  to="room@conference.muc.com/nickname">
    <x xmlns=
      "http://jabber.org/protocol/muc"/>
</presence>
XMPP: XEP-0045             (3)



<message to="room@conference.muc.com"
  from="user@domain.com/resource"
  type="groupchat ">
  <body>Lorem Ipsum</body>
</message>

<message to="otherUser@domain.com/resource"
from="room@conference.muc.com/nickname"
type="groupchat ">
<body>Lorem Ipsum</body>
</message>
Overview

•   The old days

•   XMPP

•   Install server

•   Configure apache

•   Libraries

•   Examples
Install server: starting point


•   Debian

    •   web server

    •   SQL database

    •   SSH server
Install server: apt sources

•   apt-get install vim

•   vim /etc/apt/sources.list
    •   deb http://ftp.belnet.be/debian/ squeeze main non-free
        deb-src http://ftp.belnet.be/debian/ squeeze main
        deb http://security.debian.org/ squeeze/updates main non-free
        deb-src http://security.debian.org/ squeeze/updates main
        deb http://packages.dotdeb.org stable all
        deb-src http://packages.dotdeb.org stable all
Install server: prerequisites (1)


•   wget http://www.dotdeb.org/dotdeb.gpg

•   cat dotdeb.gpg | apt-key add -

•   apt-get update

•   apt-get install sun-java6-jre sun-java6-fonts ident2
Install server: prerequisites (2)


•   apt-get install mysql-server mysql-client

•   apt-get install php5 php5-cli php5-common php5-dev
    php5-mysql php5-curl php-pear

•   Database & user
Install server: Openfire (1)

•   Openfire 3.7.0

    •   http://www.igniterealtime.org/projects/openfire/

•   wget -O openfire_3.7.0_all.deb
    http://www.igniterealtime.org/downloadServlet?
    filename=openfire/openfire_3.7.0_all.deb

•   dpkg -i openfire_3.7.0_all.deb
Install server: Openfire (2)



•   http://[server-ip]:9090/
Install server: Openfire (3)


•   Plugins

    •   User Service

    •   Monitoring Service
Overview

•   The old days

•   XMPP

•   Install server

•   Configure apache

•   Libraries

•   Examples
Configure apache: why                                    (1)



Client - polling




                             ta




                                            ta
                   ta




                                                        data
                        no da




                                       no da
              no da




Server

                                           d ata
                                       w
                                  ne




                                                 data
Client - long polling
Configure apache: why                   (2)




•   BOSH (Bidirectional streams Over Synchronous HTTP)
Configure apache: proxy (1)

•   cd /etc/apache2/mods-enabled/

•   ln -s ../mods-available/proxy.load

•   ln -s ../mods-available/proxy_http.load



•   ln -s ../mods-available/rewrite.load
Configure apache: proxy (2)
<VirtualHost *:80>
  Options FollowSymLinks
  ServerAdmin bert@becoded.be
  ServerName xmpp.dev.becoded.be
  ServerAlias static.xmpp.dev.becoded.be
  # Indexes + Directory Root.
  DirectoryIndex index.php
  DocumentRoot /var/www/vhost/xmpp.dev.becoded.be/htdocs/public/
  php_admin_value open_basedir ".:/var/www/vhost/xmpp.dev.becoded.be/htdocs:/var/www/library/Zend-latest/
library:../:/usr/share/php:/tmp"
  php_value include_path ".:/var/www/vhost/xmpp.dev.becoded.be/htdocs:/var/www/library/Zend-latest/library:/usr/
share/php"
  php_admin_value upload_tmp_dir "/tmp"
  SetEnv APPLICATION_ENV development

  # Logfiles
  ErrorLog /var/www/vhost/xmpp.dev.becoded.be/logs/error.log
  CustomLog /var/www/vhost/xmpp.dev.becoded.be/logs/access.log combined


# XMPP proxy rule
ProxyRequests Off
ProxyPass /bind http://127.0.0.1:7070/http-bind/
ProxyPassReverse /bind http://127.0.0.1:7070/http-bind/
</VirtualHost>
Overview

•   The old days

•   XMPP

•   Install server

•   Configure apache

•   Libraries

•   Examples
Libraries

•   ZF - http://framework.zend.com

•   jQuery - http://jquery.com/

•   jQuery UI - http://jqueryui.com/

•   XMPPHP - http://code.google.com/p/xmpphp

•   Jaxl - http://jaxl.net

•   Strophe.js - http://strophe.im
Libraries: XMPPHP

$connection =  new XMPPHP_XMPP(
                    $host, $port,
                    $identifier->node,
                    $identifier->password,
                    $identifier->resource,
                    $domain,
                    $printlog,
                    $loglevel);
$connection->connect();
$connection->processUntil('session_start');
$connection->message('support@demo', 'Hello world');
$connection->disconnect();
Libraries: Jaxl
$connection = new JAXL(array(
	 'user'	 	 	 => $identifier->node,
	 'pass'	 	 	 => $identifier->password,
  'host' 	 	 => $host,
          	
  'domain' 		 => $domain,
	 'port' 	 	 => $port,
          	
	 'authType'	 => 'PLAIN',
	 'logLevel'	 => $loglevel
	 ));
$connection->addPlugin('jaxl_post_auth', '_postAuthHook');
$connection->startCore("stream");

public function _postAuthHook ($payload, $jaxl) {
  $jaxl->sendMessage('support@demo', 'Hello world');
  $jaxl->shutdown();
}
Libraries: Strophe.js
var connection = new Strophe.Connection('/bind');
connection.connect(
	 jid, password,
	 function (status) {
	 	 if (status == Strophe.Status.CONNECTED) {
	 	 	 var msg = $msg({
	 	 	 	 to : 'support@demo',
	 	 	 	 type : "chat"
	 	 	 	 }).c('body').t('Hello world');
	 	 	
	 	 	 connection.send(msg);
	 	 	 setTimeout(function () {
	 	 	 	 connection.disconnect();
	 	 	 }, 500);
	 	 }
	 });
Overview

•   The old days

•   XMPP

•   Install server

•   Configure apache

•   Libraries

•   Examples
Examples: setup
Examples: messages


•   Browser

    •   Log

•   Adium
Example: IQ ping pong (1)
this.statusHandler = function (status) {
	 	 var me = this;
	 	 if (status == Strophe.Status.CONNECTED) {
	 	 	 me.connection.addHandler(
	 	 	 	 function(msg) {	 //(Function) handler
	 	 	 	 	 return me.handlePong(msg);
	 	 	 	 },
  	 	 	 null, 	 	 	 	 	 //(String) ns
	 	 	 	 'iq', 	 	 	 	 	 //(String) name
	 	 	 	 null, 	 	 	 	 	 //(String) type
	 	 	 	 'pingPong');	 	 //(String) id
                      	
	 	 	 me.sendPing(Strophe.getDomainFromJid(me.connection.jid));
	 	 }
	 };
Example: IQ ping pong (2)

this.sendPing = function (to)
{
	 var me = this;                    <iq
	                                     to='demo'
                                      type='get'
	 var iq = $iq({
                                      id='pingPong'
	 	 to	 to,
       :
                                      xmlns='jabber:client'>
	 	 type : 'get',                     	 <ping
	 	 id : 'pingPong'                        xmlns='urn:xmpp:ping'/>
	 	 }).c('ping',                    </iq>
       {xmlns: 'urn:xmpp:ping'});
	
	 me.connection.send(iq);
};
Example: IQ ping pong (3)
this.handlePong = function (msg)
{
	 var me = this;
	 var objMsg = $(msg);
	 var from = objMsg.attr('from');
	 me.log('Receiving ' + objMsg.attr('type') +
	 	 ' from "' + objMsg.attr('from') +
	 	 '" with id "' + objMsg.attr('id') + '"');
	 me.connection.disconnect();
};


<iq xmlns="jabber:client"
  type="result" id="pingPong"
  from="demo" to="demo1@demo/eeffca60"/>
Example: support chat (1)
this.bindSendMessage = function ()
{
	 var me = this;
	 var chatMsg = $('#message');
	 	
	 $('#sendMessage').bind('click', function() {
	 	 me.sendChatMessage(chatMsg.val());
	 	 me.resetTextarea(chatMsg);
	 });
	 	
	 chatMsg.keyup(function(event) {
	 	 if (event.keyCode == 13 && event.shiftKey) {
	 	 	 me.sendChatMessage(chatMsg.val());
	 	 	 me.resetTextarea(chatMsg);
	 	 }
	 });
};
Example: support chat (2)
this.statusHandler = function (status)
{
	 var me = this;
	 me.logStatus(status);
	 if (status == Strophe.Status.CONNECTED) {
	 	 me.connection.addHandler(
	 	 	 function(msg) {	 	 	 	 //(Function) handler.
	 	 	 	 return me.handleChatMessage(msg);
	 	 	 },
	 	 	 null, 	 	 	 	 	 	 	 	 //(String) ns
	 	 	 'message', 	 	 	 	 	 	 //(String) name
	 	 	 'chat'); 		 	 	 	 	 	 //(String) type
	 }
};
Example: support chat (3)

this.handleChatMessage = function (msg)
{
	 var me = this;
	
	 var objMsg = $(msg);
	 var from = objMsg.attr('from');
	 var nick = Strophe.getNodeFromJid(from);
	 var body = objMsg.children('body').text();
	
	 me.addMessageToChat(nick, body);
	
	 return true;
};
Example: support chat (4)
this.addMessageToChat = function (nick, body)
{
	 var me = this;
	 var container = $('#chat');
	 var atBottom =
       container.scrollTop() >=
          container[0].scrollHeight - container.height();
	 	
	 container.append('<dt>'+ nick +'</dt><dd>'+
     me.nl2br(body, true) +'</dd>');
	 	
	 if (atBottom) {
	 	 container.scrollTop(container[0].scrollHeight);
	 }
};
Example: statistics

this.handleHighChartData = function (msg)
{
	 var me = this;
	 	
	 var objMsg = $(msg);
   var body = objMsg.children('body').text();
	 	
	 me.chart.series[0].setData(jQuery.parseJSON(body));
	 return true;
};
Example: prebind BOSH (1)

•   SID - RID

•   Security

•   User friendly

•   Performance

•   Persisting
Example: prebind BOSH(2)
this.initConnection = function ()
{
	 var me = this;

	 me.connection = new Strophe.Connection(me.httpBindUrl);
	
	 me.connection.attach(
	 	 me.options.service.jid,
	 	 me.options.service.sid,
	 	 me.options.service.rid,
	 	 function (status) {
	 	 	 me.statusHandler(status);
	 	 });
};
Books
Thank you


•   bert@becoded.be

•   Code: https://github.com/becoded/talk-xmpp-demo

•   Slides: Slideshare

•   Rate / comments: http://joind.in/3778
Questions



?   ?   ?   ?

Contenu connexe

Tendances

PHP language presentation
PHP language presentationPHP language presentation
PHP language presentationAnnujj Agrawaal
 
Talking Heads - writing an API does not need to be a "psycho killer"
Talking Heads - writing an API does not need to be a "psycho killer"Talking Heads - writing an API does not need to be a "psycho killer"
Talking Heads - writing an API does not need to be a "psycho killer"Theo van Hoesel
 
Using and scaling Rack and Rack-based middleware
Using and scaling Rack and Rack-based middlewareUsing and scaling Rack and Rack-based middleware
Using and scaling Rack and Rack-based middlewareAlona Mekhovova
 
Ruby HTTP clients comparison
Ruby HTTP clients comparisonRuby HTTP clients comparison
Ruby HTTP clients comparisonHiroshi Nakamura
 
Async Tasks with Django Channels
Async Tasks with Django ChannelsAsync Tasks with Django Channels
Async Tasks with Django ChannelsAlbert O'Connor
 
ReST-ful Resource Management
ReST-ful Resource ManagementReST-ful Resource Management
ReST-ful Resource ManagementJoe Davis
 
HTML5: friend or foe (to Flash)?
HTML5: friend or foe (to Flash)?HTML5: friend or foe (to Flash)?
HTML5: friend or foe (to Flash)?Remy Sharp
 
The worst Ruby codes I’ve seen in my life - RubyKaigi 2015
The worst Ruby codes I’ve seen in my life - RubyKaigi 2015The worst Ruby codes I’ve seen in my life - RubyKaigi 2015
The worst Ruby codes I’ve seen in my life - RubyKaigi 2015Fernando Hamasaki de Amorim
 
XMPP Technical Overview + Jingle Protocol Study
XMPP Technical Overview + Jingle Protocol StudyXMPP Technical Overview + Jingle Protocol Study
XMPP Technical Overview + Jingle Protocol StudyValérian Saliou
 
Eve - REST API for Humans™
Eve - REST API for Humans™Eve - REST API for Humans™
Eve - REST API for Humans™Nicola Iarocci
 
Beyond 'Set it and Forget it': Proactively managing your EZproxy server
Beyond 'Set it and Forget it': Proactively managing your EZproxy serverBeyond 'Set it and Forget it': Proactively managing your EZproxy server
Beyond 'Set it and Forget it': Proactively managing your EZproxy serverNASIG
 
Modern Web Development with Perl
Modern Web Development with PerlModern Web Development with Perl
Modern Web Development with PerlDave Cross
 
DEF CON 27- ALBINOWAX - http desync attacks
DEF CON 27- ALBINOWAX - http desync attacksDEF CON 27- ALBINOWAX - http desync attacks
DEF CON 27- ALBINOWAX - http desync attacksFelipe Prado
 
Resource-Oriented Web Services
Resource-Oriented Web ServicesResource-Oriented Web Services
Resource-Oriented Web ServicesBradley Holt
 
8 Minutes On Rack
8 Minutes On Rack8 Minutes On Rack
8 Minutes On Rackdanwrong
 

Tendances (20)

PHP language presentation
PHP language presentationPHP language presentation
PHP language presentation
 
Talking Heads - writing an API does not need to be a "psycho killer"
Talking Heads - writing an API does not need to be a "psycho killer"Talking Heads - writing an API does not need to be a "psycho killer"
Talking Heads - writing an API does not need to be a "psycho killer"
 
Using and scaling Rack and Rack-based middleware
Using and scaling Rack and Rack-based middlewareUsing and scaling Rack and Rack-based middleware
Using and scaling Rack and Rack-based middleware
 
Ruby HTTP clients comparison
Ruby HTTP clients comparisonRuby HTTP clients comparison
Ruby HTTP clients comparison
 
WP HTTP API
WP HTTP APIWP HTTP API
WP HTTP API
 
Async Tasks with Django Channels
Async Tasks with Django ChannelsAsync Tasks with Django Channels
Async Tasks with Django Channels
 
ReST-ful Resource Management
ReST-ful Resource ManagementReST-ful Resource Management
ReST-ful Resource Management
 
HTML5: friend or foe (to Flash)?
HTML5: friend or foe (to Flash)?HTML5: friend or foe (to Flash)?
HTML5: friend or foe (to Flash)?
 
The worst Ruby codes I’ve seen in my life - RubyKaigi 2015
The worst Ruby codes I’ve seen in my life - RubyKaigi 2015The worst Ruby codes I’ve seen in my life - RubyKaigi 2015
The worst Ruby codes I’ve seen in my life - RubyKaigi 2015
 
XMPP Technical Overview + Jingle Protocol Study
XMPP Technical Overview + Jingle Protocol StudyXMPP Technical Overview + Jingle Protocol Study
XMPP Technical Overview + Jingle Protocol Study
 
Eve - REST API for Humans™
Eve - REST API for Humans™Eve - REST API for Humans™
Eve - REST API for Humans™
 
Develop webservice in PHP
Develop webservice in PHPDevelop webservice in PHP
Develop webservice in PHP
 
Plack - LPW 2009
Plack - LPW 2009Plack - LPW 2009
Plack - LPW 2009
 
DDS and XMPP
DDS and XMPPDDS and XMPP
DDS and XMPP
 
Beyond 'Set it and Forget it': Proactively managing your EZproxy server
Beyond 'Set it and Forget it': Proactively managing your EZproxy serverBeyond 'Set it and Forget it': Proactively managing your EZproxy server
Beyond 'Set it and Forget it': Proactively managing your EZproxy server
 
Modern Web Development with Perl
Modern Web Development with PerlModern Web Development with Perl
Modern Web Development with Perl
 
DEF CON 27- ALBINOWAX - http desync attacks
DEF CON 27- ALBINOWAX - http desync attacksDEF CON 27- ALBINOWAX - http desync attacks
DEF CON 27- ALBINOWAX - http desync attacks
 
Real-Time Django
Real-Time DjangoReal-Time Django
Real-Time Django
 
Resource-Oriented Web Services
Resource-Oriented Web ServicesResource-Oriented Web Services
Resource-Oriented Web Services
 
8 Minutes On Rack
8 Minutes On Rack8 Minutes On Rack
8 Minutes On Rack
 

En vedette

Introduction à Sinatra
Introduction à SinatraIntroduction à Sinatra
Introduction à SinatraRémi Prévost
 
Aloha editor contenteditable useable
Aloha editor contenteditable useableAloha editor contenteditable useable
Aloha editor contenteditable useableHaymo Meran
 
Open Source Communities (PHP Benelux Keynote)
Open Source Communities (PHP Benelux Keynote)Open Source Communities (PHP Benelux Keynote)
Open Source Communities (PHP Benelux Keynote)enaramore
 
Confoo 2012-03-01 - Building mobile experiences that don't suck
Confoo 2012-03-01 - Building mobile experiences that don't suckConfoo 2012-03-01 - Building mobile experiences that don't suck
Confoo 2012-03-01 - Building mobile experiences that don't suckFrédéric Harper
 
Symfony2 - from the trenches
Symfony2 - from the trenchesSymfony2 - from the trenches
Symfony2 - from the trenchesLukas Smith
 

En vedette (6)

Introduction à Sinatra
Introduction à SinatraIntroduction à Sinatra
Introduction à Sinatra
 
Aloha editor contenteditable useable
Aloha editor contenteditable useableAloha editor contenteditable useable
Aloha editor contenteditable useable
 
Open Source Communities (PHP Benelux Keynote)
Open Source Communities (PHP Benelux Keynote)Open Source Communities (PHP Benelux Keynote)
Open Source Communities (PHP Benelux Keynote)
 
Confoo 2012-03-01 - Building mobile experiences that don't suck
Confoo 2012-03-01 - Building mobile experiences that don't suckConfoo 2012-03-01 - Building mobile experiences that don't suck
Confoo 2012-03-01 - Building mobile experiences that don't suck
 
PHP Reset
PHP ResetPHP Reset
PHP Reset
 
Symfony2 - from the trenches
Symfony2 - from the trenchesSymfony2 - from the trenches
Symfony2 - from the trenches
 

Similaire à Powering your website with realtime data

XMPP Intro 1101 - 2008
XMPP Intro 1101 - 2008XMPP Intro 1101 - 2008
XMPP Intro 1101 - 2008Steffen Larsen
 
Powering your website with realtime data
Powering your website with realtime dataPowering your website with realtime data
Powering your website with realtime databecoded
 
Fluentd and Embulk Game Server 4
Fluentd and Embulk Game Server 4Fluentd and Embulk Game Server 4
Fluentd and Embulk Game Server 4N Masahiro
 
Rapid java backend and api development for mobile devices
Rapid java backend and api development for mobile devicesRapid java backend and api development for mobile devices
Rapid java backend and api development for mobile devicesciklum_ods
 
Netconf for Peering Automation by Tom Paseka [APRICOT 2015]
Netconf for Peering Automation by Tom Paseka [APRICOT 2015]Netconf for Peering Automation by Tom Paseka [APRICOT 2015]
Netconf for Peering Automation by Tom Paseka [APRICOT 2015]APNIC
 
APRICOT 2015 - NetConf for Peering Automation
APRICOT 2015 - NetConf for Peering AutomationAPRICOT 2015 - NetConf for Peering Automation
APRICOT 2015 - NetConf for Peering AutomationTom Paseka
 
Site Performance - From Pinto to Ferrari
Site Performance - From Pinto to FerrariSite Performance - From Pinto to Ferrari
Site Performance - From Pinto to FerrariJoseph Scott
 
Socket applications
Socket applicationsSocket applications
Socket applicationsJoão Moura
 
CouchDB for Web Applications - Erlang Factory London 2009
CouchDB for Web Applications - Erlang Factory London 2009CouchDB for Web Applications - Erlang Factory London 2009
CouchDB for Web Applications - Erlang Factory London 2009Jason Davies
 
Gaelyk - JFokus 2011 - Guillaume Laforge
Gaelyk - JFokus 2011 - Guillaume LaforgeGaelyk - JFokus 2011 - Guillaume Laforge
Gaelyk - JFokus 2011 - Guillaume LaforgeGuillaume Laforge
 
Scalalable Language for a Scalable Web
Scalalable Language for a Scalable WebScalalable Language for a Scalable Web
Scalalable Language for a Scalable WebTimothy Perrett
 
Apache Wizardry - Ohio Linux 2011
Apache Wizardry - Ohio Linux 2011Apache Wizardry - Ohio Linux 2011
Apache Wizardry - Ohio Linux 2011Rich Bowen
 

Similaire à Powering your website with realtime data (20)

XMPP Intro 1101 - 2008
XMPP Intro 1101 - 2008XMPP Intro 1101 - 2008
XMPP Intro 1101 - 2008
 
Powering your website with realtime data
Powering your website with realtime dataPowering your website with realtime data
Powering your website with realtime data
 
Fluentd and Embulk Game Server 4
Fluentd and Embulk Game Server 4Fluentd and Embulk Game Server 4
Fluentd and Embulk Game Server 4
 
Rapid java backend and api development for mobile devices
Rapid java backend and api development for mobile devicesRapid java backend and api development for mobile devices
Rapid java backend and api development for mobile devices
 
Netconf for Peering Automation by Tom Paseka [APRICOT 2015]
Netconf for Peering Automation by Tom Paseka [APRICOT 2015]Netconf for Peering Automation by Tom Paseka [APRICOT 2015]
Netconf for Peering Automation by Tom Paseka [APRICOT 2015]
 
APRICOT 2015 - NetConf for Peering Automation
APRICOT 2015 - NetConf for Peering AutomationAPRICOT 2015 - NetConf for Peering Automation
APRICOT 2015 - NetConf for Peering Automation
 
Mojolicious
MojoliciousMojolicious
Mojolicious
 
Html5 intro
Html5 introHtml5 intro
Html5 intro
 
Camel as a_glue
Camel as a_glueCamel as a_glue
Camel as a_glue
 
Site Performance - From Pinto to Ferrari
Site Performance - From Pinto to FerrariSite Performance - From Pinto to Ferrari
Site Performance - From Pinto to Ferrari
 
Sinatra for REST services
Sinatra for REST servicesSinatra for REST services
Sinatra for REST services
 
Rails 4.0
Rails 4.0Rails 4.0
Rails 4.0
 
Socket applications
Socket applicationsSocket applications
Socket applications
 
CouchDB for Web Applications - Erlang Factory London 2009
CouchDB for Web Applications - Erlang Factory London 2009CouchDB for Web Applications - Erlang Factory London 2009
CouchDB for Web Applications - Erlang Factory London 2009
 
Logstash
LogstashLogstash
Logstash
 
Gaelyk - JFokus 2011 - Guillaume Laforge
Gaelyk - JFokus 2011 - Guillaume LaforgeGaelyk - JFokus 2011 - Guillaume Laforge
Gaelyk - JFokus 2011 - Guillaume Laforge
 
Rack
RackRack
Rack
 
Scalalable Language for a Scalable Web
Scalalable Language for a Scalable WebScalalable Language for a Scalable Web
Scalalable Language for a Scalable Web
 
Html 5
Html 5Html 5
Html 5
 
Apache Wizardry - Ohio Linux 2011
Apache Wizardry - Ohio Linux 2011Apache Wizardry - Ohio Linux 2011
Apache Wizardry - Ohio Linux 2011
 

Dernier

Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 

Dernier (20)

Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 

Powering your website with realtime data

  • 1. October 2011 Powering your website with realtime data Bert Van Hauwaert bert@becoded.be - @tbotwit
  • 2. Bert Van Hauwaert • Live in Belgium • Founder of be.coded • Freelance web application developer & consultant • ZCE 5.0 • Working on realtime auction sites
  • 3. Overview • The old days • XMPP • Install server • Configure apache • Libraries • Examples
  • 4. Overview • The old days • XMPP • Install server • Configure apache • Libraries • Examples
  • 5. The old days • <meta http-equiv=”refresh” content=”5” /> • <script > • AJAX
  • 6. Overview • The old days • XMPP • Install server • Configure apache • Libraries • Examples
  • 7. XMPP: what • Extensible Messaging and Presence Protocol • Jabber • XML • Client - Server - Component
  • 8. XMPP: stanzas • <presence> • <message> • <iq>
  • 9. XMPP: stanzas • <presence> • <message> • <iq>
  • 10. XMPP: stanzas • <presence> • <message> • <iq>
  • 11. XMPP: stanzas • <presence> • <message> • <iq>
  • 12. XMPP: addressing • JID (Jabber Identifier) • Three main parts • [ node "@" ] domain [ "/" resource ]
  • 13. XMPP: extensions • XMPP Extension Protocol - XEP • http://xmpp.org/xmpp-protocols/xmpp-extensions/
  • 14. XMPP: advantages • Open • Decentralized • Secure • Extensible
  • 15. XMPP: disadvantages • Statefulness • Overhead
  • 16. XMPP: example <stream:stream> <iq type="get" id="roster1"> <query xmlns:"jabber:iq:roster" /> </iq> <presence /> <message to="attendees@zendcon.com" from="bert@becoded.be/speakerroom" type="chat"> <body> I hope you will enjoy this talk </body> </message> <presence> <show>dnd</show> <status>Giving a talk @ ZendCon</status> </presence> </stream:stream>
  • 17. XMPP: example <stream:stream> <iq type="get" id="roster1"> <query xmlns:"jabber:iq:roster" /> </iq> <presence /> <message to="attendees@zendcon.com" from="bert@becoded.be/speakerroom" type="chat"> <body> I hope you will enjoy this talk </body> </message> <presence> <show>dnd</show> <status>Giving a talk @ ZendCon</status> </presence> </stream:stream>
  • 18. XMPP: example <stream:stream> <iq type="get" id="roster1"> <query xmlns:"jabber:iq:roster" /> </iq> <presence /> <message to="attendees@zendcon.com" from="bert@becoded.be/speakerroom" type="chat"> <body> I hope you will enjoy this talk </body> </message> <presence> <show>dnd</show> <status>Giving a talk @ ZendCon</status> </presence> </stream:stream>
  • 19. XMPP: example <stream:stream> <iq type="get" id="roster1"> <query xmlns:"jabber:iq:roster" /> </iq> <presence /> <message to="attendees@zendcon.com" from="bert@becoded.be/speakerroom" type="chat"> <body> I hope you will enjoy this talk </body> </message> <presence> <show>dnd</show> <status>Giving a talk @ ZendCon</status> </presence> </stream:stream>
  • 20. XMPP: example <stream:stream> <iq type="get" id="roster1"> <query xmlns:"jabber:iq:roster" /> </iq> <presence /> <message to="attendees@zendcon.com" from="bert@becoded.be/speakerroom" type="chat"> <body> I hope you will enjoy this talk </body> </message> <presence> <show>dnd</show> <status>Giving a talk @ ZendCon</status> </presence> </stream:stream>
  • 21. XMPP: example <stream:stream> <iq type="get" id="roster1"> <query xmlns:"jabber:iq:roster" /> </iq> <presence /> <message to="attendees@zendcon.com" from="bert@becoded.be/speakerroom" type="chat"> <body> I hope you will enjoy this talk </body> </message> <presence> <show>dnd</show> <status> Giving a talk @ ZendCon </status> </presence> </stream:stream>
  • 22. XMPP: example <stream:stream> <iq type="get" id="roster1"> <query xmlns:"jabber:iq:roster" /> </iq> <presence /> <message to="attendees@zendcon.com" from="bert@becoded.be/speakerroom" type="chat"> <body> I hope you will enjoy this talk </body> </message> <presence> <show>dnd</show> <status> Giving a talk @ ZendCon </status> </presence> </stream:stream>
  • 23. XMPP: XEP-0060 (1) • PubSub (Publish / Subscribe) • Bandwidth / resources
  • 24. XMPP: XEP-0060 (2) <iq from="child@holiday.com/car" id="ams9nz78" to="pubsub.holiday.com" type="set"> <pubsub xmlns="http://jabber.org/ protocol/pubsub"> <subscribe node="are-we-there-yet" jid="child@holiday.com"/> </pubsub> </iq>
  • 25. XMPP: XEP-0060 (3) <iq from="adult@holiday.com/car" id="wmn78e45a" to="pubsub.holiday.com" type="set"> <pubsub xmlns="http://jabber.org/protocol/pubsub"> <publish node="are-we-there-yet"> <item> <there xmlns="http://holiday.com/there-yet" status="true"/> </item> </publish> </pubsub> </iq>
  • 26. XMPP: XEP-0060 (4) <message from="pubsub.holiday.com" to="child@holiday.com"> <event xmlns="http://jabber.org/protocol/pubsub#event"> <items node="are-we-there-yet"> <item id="ax78ui789q"> <there xmlns="http://holiday.com/there-yet" status="true"/> </item> </items> </event> </message>
  • 27. XMPP: XEP-0045 (1) • MUC / Multi-User Chat • “Multiplier”
  • 28. XMPP: XEP-0045 (2) <presence from="user@domain.com/resource" to="room@conference.muc.com/nickname"> <x xmlns= "http://jabber.org/protocol/muc"/> </presence>
  • 29. XMPP: XEP-0045 (3) <message to="room@conference.muc.com" from="user@domain.com/resource" type="groupchat "> <body>Lorem Ipsum</body> </message> <message to="otherUser@domain.com/resource" from="room@conference.muc.com/nickname" type="groupchat "> <body>Lorem Ipsum</body> </message>
  • 30. Overview • The old days • XMPP • Install server • Configure apache • Libraries • Examples
  • 31. Install server: starting point • Debian • web server • SQL database • SSH server
  • 32. Install server: apt sources • apt-get install vim • vim /etc/apt/sources.list • deb http://ftp.belnet.be/debian/ squeeze main non-free deb-src http://ftp.belnet.be/debian/ squeeze main deb http://security.debian.org/ squeeze/updates main non-free deb-src http://security.debian.org/ squeeze/updates main deb http://packages.dotdeb.org stable all deb-src http://packages.dotdeb.org stable all
  • 33. Install server: prerequisites (1) • wget http://www.dotdeb.org/dotdeb.gpg • cat dotdeb.gpg | apt-key add - • apt-get update • apt-get install sun-java6-jre sun-java6-fonts ident2
  • 34. Install server: prerequisites (2) • apt-get install mysql-server mysql-client • apt-get install php5 php5-cli php5-common php5-dev php5-mysql php5-curl php-pear • Database & user
  • 35. Install server: Openfire (1) • Openfire 3.7.0 • http://www.igniterealtime.org/projects/openfire/ • wget -O openfire_3.7.0_all.deb http://www.igniterealtime.org/downloadServlet? filename=openfire/openfire_3.7.0_all.deb • dpkg -i openfire_3.7.0_all.deb
  • 36. Install server: Openfire (2) • http://[server-ip]:9090/
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44. Install server: Openfire (3) • Plugins • User Service • Monitoring Service
  • 45. Overview • The old days • XMPP • Install server • Configure apache • Libraries • Examples
  • 46. Configure apache: why (1) Client - polling ta ta ta data no da no da no da Server d ata w ne data Client - long polling
  • 47. Configure apache: why (2) • BOSH (Bidirectional streams Over Synchronous HTTP)
  • 48. Configure apache: proxy (1) • cd /etc/apache2/mods-enabled/ • ln -s ../mods-available/proxy.load • ln -s ../mods-available/proxy_http.load • ln -s ../mods-available/rewrite.load
  • 49. Configure apache: proxy (2) <VirtualHost *:80> Options FollowSymLinks ServerAdmin bert@becoded.be ServerName xmpp.dev.becoded.be ServerAlias static.xmpp.dev.becoded.be # Indexes + Directory Root. DirectoryIndex index.php DocumentRoot /var/www/vhost/xmpp.dev.becoded.be/htdocs/public/ php_admin_value open_basedir ".:/var/www/vhost/xmpp.dev.becoded.be/htdocs:/var/www/library/Zend-latest/ library:../:/usr/share/php:/tmp" php_value include_path ".:/var/www/vhost/xmpp.dev.becoded.be/htdocs:/var/www/library/Zend-latest/library:/usr/ share/php" php_admin_value upload_tmp_dir "/tmp" SetEnv APPLICATION_ENV development # Logfiles ErrorLog /var/www/vhost/xmpp.dev.becoded.be/logs/error.log CustomLog /var/www/vhost/xmpp.dev.becoded.be/logs/access.log combined # XMPP proxy rule ProxyRequests Off ProxyPass /bind http://127.0.0.1:7070/http-bind/ ProxyPassReverse /bind http://127.0.0.1:7070/http-bind/ </VirtualHost>
  • 50. Overview • The old days • XMPP • Install server • Configure apache • Libraries • Examples
  • 51. Libraries • ZF - http://framework.zend.com • jQuery - http://jquery.com/ • jQuery UI - http://jqueryui.com/ • XMPPHP - http://code.google.com/p/xmpphp • Jaxl - http://jaxl.net • Strophe.js - http://strophe.im
  • 52. Libraries: XMPPHP $connection = new XMPPHP_XMPP( $host, $port, $identifier->node, $identifier->password, $identifier->resource, $domain, $printlog, $loglevel); $connection->connect(); $connection->processUntil('session_start'); $connection->message('support@demo', 'Hello world'); $connection->disconnect();
  • 53. Libraries: Jaxl $connection = new JAXL(array( 'user' => $identifier->node, 'pass' => $identifier->password, 'host' => $host, 'domain' => $domain, 'port' => $port, 'authType' => 'PLAIN', 'logLevel' => $loglevel )); $connection->addPlugin('jaxl_post_auth', '_postAuthHook'); $connection->startCore("stream"); public function _postAuthHook ($payload, $jaxl) { $jaxl->sendMessage('support@demo', 'Hello world'); $jaxl->shutdown(); }
  • 54. Libraries: Strophe.js var connection = new Strophe.Connection('/bind'); connection.connect( jid, password, function (status) { if (status == Strophe.Status.CONNECTED) { var msg = $msg({ to : 'support@demo', type : "chat" }).c('body').t('Hello world'); connection.send(msg); setTimeout(function () { connection.disconnect(); }, 500); } });
  • 55. Overview • The old days • XMPP • Install server • Configure apache • Libraries • Examples
  • 57.
  • 58. Examples: messages • Browser • Log • Adium
  • 59.
  • 60.
  • 61. Example: IQ ping pong (1) this.statusHandler = function (status) { var me = this; if (status == Strophe.Status.CONNECTED) { me.connection.addHandler( function(msg) { //(Function) handler return me.handlePong(msg); }, null, //(String) ns 'iq', //(String) name null, //(String) type 'pingPong'); //(String) id me.sendPing(Strophe.getDomainFromJid(me.connection.jid)); } };
  • 62. Example: IQ ping pong (2) this.sendPing = function (to) { var me = this; <iq to='demo' type='get' var iq = $iq({ id='pingPong' to to, : xmlns='jabber:client'> type : 'get', <ping id : 'pingPong' xmlns='urn:xmpp:ping'/> }).c('ping', </iq> {xmlns: 'urn:xmpp:ping'}); me.connection.send(iq); };
  • 63. Example: IQ ping pong (3) this.handlePong = function (msg) { var me = this; var objMsg = $(msg); var from = objMsg.attr('from'); me.log('Receiving ' + objMsg.attr('type') + ' from "' + objMsg.attr('from') + '" with id "' + objMsg.attr('id') + '"'); me.connection.disconnect(); }; <iq xmlns="jabber:client" type="result" id="pingPong" from="demo" to="demo1@demo/eeffca60"/>
  • 64.
  • 65. Example: support chat (1) this.bindSendMessage = function () { var me = this; var chatMsg = $('#message'); $('#sendMessage').bind('click', function() { me.sendChatMessage(chatMsg.val()); me.resetTextarea(chatMsg); }); chatMsg.keyup(function(event) { if (event.keyCode == 13 && event.shiftKey) { me.sendChatMessage(chatMsg.val()); me.resetTextarea(chatMsg); } }); };
  • 66. Example: support chat (2) this.statusHandler = function (status) { var me = this; me.logStatus(status); if (status == Strophe.Status.CONNECTED) { me.connection.addHandler( function(msg) { //(Function) handler. return me.handleChatMessage(msg); }, null, //(String) ns 'message', //(String) name 'chat'); //(String) type } };
  • 67. Example: support chat (3) this.handleChatMessage = function (msg) { var me = this; var objMsg = $(msg); var from = objMsg.attr('from'); var nick = Strophe.getNodeFromJid(from); var body = objMsg.children('body').text(); me.addMessageToChat(nick, body); return true; };
  • 68. Example: support chat (4) this.addMessageToChat = function (nick, body) { var me = this; var container = $('#chat'); var atBottom = container.scrollTop() >= container[0].scrollHeight - container.height(); container.append('<dt>'+ nick +'</dt><dd>'+ me.nl2br(body, true) +'</dd>'); if (atBottom) { container.scrollTop(container[0].scrollHeight); } };
  • 69.
  • 70. Example: statistics this.handleHighChartData = function (msg) { var me = this; var objMsg = $(msg); var body = objMsg.children('body').text(); me.chart.series[0].setData(jQuery.parseJSON(body)); return true; };
  • 71.
  • 72.
  • 73. Example: prebind BOSH (1) • SID - RID • Security • User friendly • Performance • Persisting
  • 74. Example: prebind BOSH(2) this.initConnection = function () { var me = this; me.connection = new Strophe.Connection(me.httpBindUrl); me.connection.attach( me.options.service.jid, me.options.service.sid, me.options.service.rid, function (status) { me.statusHandler(status); }); };
  • 75.
  • 76.
  • 77. Books
  • 78. Thank you • bert@becoded.be • Code: https://github.com/becoded/talk-xmpp-demo • Slides: Slideshare • Rate / comments: http://joind.in/3778
  • 79. Questions ? ? ? ?