Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Microblogging with XMPP
        Real Time Web
Who am I?

• Name: Stoyan Zhekov
• Private: married, 3 kids (boys)
• Work: Software Engineer
• Contact: xmpp: //zh@jabber....
Today

• XMPP (Jabber)
• Microblogging
• Microblogging with XMPP
• My program - xmpp4r, ramaze, sequel
• Questions
Why?

• Web 3.0 ? - Real Time Web?
• RSS is not enough (SUP)
• XMPP (Jabber)
• Webhooks
XMPP (Jabber)
London-Calcutta, message + reply
              (Peter Saint-Andre)


• 1800:   2 years (ship)
• 1914:   1 month (steamship...
XMPP (history)

• 1998: Jeremie Miller - ICQ - AIM (perl)
• 1999: First rellease
• 2001: Jabber Software Fondation
• 2004:...
What is XMPP?

• JID: node@server/Resource
• Open Protocol
• Decentralized - no central server
• RFC 3290 (core), 3291 (me...
What is XMPP? (2)
• Bidirectional, streaming XML
• One first level tag: <stream>
• 3 second level tags:
   • <presence> - p...
XMPP Features

• Build-in presence
• One-to-one IM (u2u, a2u, a2a)
• Groupchat
• Geolocation
• Security - SSL, TLS
Not only for geeks

• 50 000+ servers, 50+ million users
• Wall Street
• US Department of Defense
• Cisco, Google, Apple
•...
You on XMPP

• Free account - jabber.jp etc.
• GTalk for domains
• Install your own server:
    • ejabberd (erlang) - prod...
Libraries

• For a lot of OSes and languages
• loudmouth (C)
• xiff (flash)
• smack (java)
• xmpp4r (ruby)
Microblogging
Microblogging

• Web 2.0
• What is it?
   • Status changes
   • Short notes (140 limit)
   • Media files
Big players

• Twitter
• Jaiku
• identi.ca (laconi.ca) - OSS
• Tumblr - http://tt.zhekov.net/
• FriendFeed, Lifestream.fm
Microblogging with XMPP
   http://www.microblog.org/
Almost Real Time

• XMPP bots (Jaiku, Identi.ca, FriendFeed)
• GNIP - http://www.gnipcentral.com/
• RSS-to-XMPP
   • http:...
Microblogging with XMPP

• Web 3.0 (Real Time Web)
• PubSub - XEP-0060
• BOSH - XEP-0124
• XEP-XXXX
• ....
Too complicated :(
Am I stupid...? :(
My own program
Design

• XMPP bot
• Simple API
• Simple web frontend
• Models: juick.com , kwippy.com
Components

• models.rb - connection to the DB
• bot.rb - XMPP
• api.rb - service, scaling
• web.rb - browser view
Models
• “Things”
   • User
   • Micro
• “Relations”
   • Subscribe - User-to-User
   • Subscribe - User-to-Micro
   • Lik...
Relations (Sequel)
class User < Sequel::Model(:users)
 one_to_many :micros do |ds|
  ds.filter(:parent_id => nil)
 end
 one...
Ruby XMPP Libraries

• xmpp4r - Roster, vCard etc.
• xmpp4r-simple - easy to use
• jabber4r - Thread based :(
XMPP Bot

• http://tr.im/emxmpp (nutrun.com)
• EventMachine - libevent, Deferrable
• Plugins - http://tr.im/modular
Concurrency
EM.run do
 EM::PeriodicTimer.new(1) do
  ...
      EM.spawn do
       worker = Worker.new
       worker.callba...
Plugins 1/3
PluginFactory.load quot;pluginsquot;
...
def PluginFactory.load( dirname )
    Dir.open( dirname ).each do |fn...
Plugins 2/3
class Plugin
   include EM::Deferrable

  def process( args = {} )
    sleep(0.05)
    set_deferred_status :su...
Plugins 3/3
class NickPlugin < Plugin
  def process(args = {})
   begin
     ...
     set_deferred_status :succeeded
   re...
Simple API (json)

• /users - list of users
• /user/<nick>/<secret> - info for user
• /status/<nick>/<secret> - presence
•...
Web (Ramaze)
class MainController < Ramaze::Controller
  def u nick
   begin
     @user = User.find_by_user(nick)
     subs...
<Demo>
To Do

• Commands parser - Ragel?
• OAuth or http://xmppid.net/
• TokyoCabinet
• XMPP Component -    http://github.com/jul...
Conclusion

• XMPP - good, open protocol
• xmpp4r-simple - good, easy to use
• eventmachine - good network library
• seque...
Questions?
</stream:stream>
Upcoming SlideShare
Loading in …5
×

Microblogging via XMPP

7,258 views

Published on

Published in: Technology

Microblogging via XMPP

  1. 1. Microblogging with XMPP Real Time Web
  2. 2. Who am I? • Name: Stoyan Zhekov • Private: married, 3 kids (boys) • Work: Software Engineer • Contact: xmpp: //zh@jabber.jp
  3. 3. Today • XMPP (Jabber) • Microblogging • Microblogging with XMPP • My program - xmpp4r, ramaze, sequel • Questions
  4. 4. Why? • Web 3.0 ? - Real Time Web? • RSS is not enough (SUP) • XMPP (Jabber) • Webhooks
  5. 5. XMPP (Jabber)
  6. 6. London-Calcutta, message + reply (Peter Saint-Andre) • 1800: 2 years (ship) • 1914: 1 month (steamship) • 1950: 1 week (airmail) • 1980: 2 days (overnight mail) • 1994: 10 min (email) • 1999: 1 sec (IM)
  7. 7. XMPP (history) • 1998: Jeremie Miller - ICQ - AIM (perl) • 1999: First rellease • 2001: Jabber Software Fondation • 2004: XMPP RFCs (IETF)
  8. 8. What is XMPP? • JID: node@server/Resource • Open Protocol • Decentralized - no central server • RFC 3290 (core), 3291 (messaging) • XMPP extension protocols (XEP)
  9. 9. What is XMPP? (2) • Bidirectional, streaming XML • One first level tag: <stream> • 3 second level tags: • <presence> - presence, subscribtion • <message> - asynchronous • <iq> - synchronous
  10. 10. XMPP Features • Build-in presence • One-to-one IM (u2u, a2u, a2a) • Groupchat • Geolocation • Security - SSL, TLS
  11. 11. Not only for geeks • 50 000+ servers, 50+ million users • Wall Street • US Department of Defense • Cisco, Google, Apple • NTT ?
  12. 12. You on XMPP • Free account - jabber.jp etc. • GTalk for domains • Install your own server: • ejabberd (erlang) - production • openfire (java) - easy to install / use
  13. 13. Libraries • For a lot of OSes and languages • loudmouth (C) • xiff (flash) • smack (java) • xmpp4r (ruby)
  14. 14. Microblogging
  15. 15. Microblogging • Web 2.0 • What is it? • Status changes • Short notes (140 limit) • Media files
  16. 16. Big players • Twitter • Jaiku • identi.ca (laconi.ca) - OSS • Tumblr - http://tt.zhekov.net/ • FriendFeed, Lifestream.fm
  17. 17. Microblogging with XMPP http://www.microblog.org/
  18. 18. Almost Real Time • XMPP bots (Jaiku, Identi.ca, FriendFeed) • GNIP - http://www.gnipcentral.com/ • RSS-to-XMPP • http://notify.me/ • http://notifixio.us/ (WP plugin)
  19. 19. Microblogging with XMPP • Web 3.0 (Real Time Web) • PubSub - XEP-0060 • BOSH - XEP-0124 • XEP-XXXX • ....
  20. 20. Too complicated :(
  21. 21. Am I stupid...? :(
  22. 22. My own program
  23. 23. Design • XMPP bot • Simple API • Simple web frontend • Models: juick.com , kwippy.com
  24. 24. Components • models.rb - connection to the DB • bot.rb - XMPP • api.rb - service, scaling • web.rb - browser view
  25. 25. Models • “Things” • User • Micro • “Relations” • Subscribe - User-to-User • Subscribe - User-to-Micro • Like - User-to-Micro
  26. 26. Relations (Sequel) class User < Sequel::Model(:users) one_to_many :micros do |ds| ds.filter(:parent_id => nil) end one_to_many :subs, :extend => UserFindOrCreate many_to_many :publishers, :class => :User, :join_table => :subs end
  27. 27. Ruby XMPP Libraries • xmpp4r - Roster, vCard etc. • xmpp4r-simple - easy to use • jabber4r - Thread based :(
  28. 28. XMPP Bot • http://tr.im/emxmpp (nutrun.com) • EventMachine - libevent, Deferrable • Plugins - http://tr.im/modular
  29. 29. Concurrency EM.run do EM::PeriodicTimer.new(1) do ... EM.spawn do worker = Worker.new worker.callback {jabber.deliver(message.from, quot;Donequot;)} worker.process end.notify ... end end class Worker include EM::Deferrable def process ... set_deferred_status :succeeded end end
  30. 30. Plugins 1/3 PluginFactory.load quot;pluginsquot; ... def PluginFactory.load( dirname ) Dir.open( dirname ).each do |fn| next unless ( fn =~ /[.]rb$/ ) require quot;#{dirname}/#{fn}quot; end end
  31. 31. Plugins 2/3 class Plugin include EM::Deferrable def process( args = {} ) sleep(0.05) set_deferred_status :succeeded end end
  32. 32. Plugins 3/3 class NickPlugin < Plugin def process(args = {}) begin ... set_deferred_status :succeeded rescue set_deferred_status :failed end end end class NickFactory < PluginFactory INFO=<<INFO verb: NICK author: Stoyan Zhekov description: Get or set the nickname for some user INFO def create() return NickPlugin.new() end end
  33. 33. Simple API (json) • /users - list of users • /user/<nick>/<secret> - info for user • /status/<nick>/<secret> - presence • /micros/<page>/<format> - list of micros • /micro/<id>/<secret> - micro + comments
  34. 34. Web (Ramaze) class MainController < Ramaze::Controller def u nick begin @user = User.find_by_user(nick) subset = @user.micros.reverse @micros, @pager = paginate(subset, :limit => PAGE) rescue Exception => e flash[:error] = quot;Error: #{e.to_s}quot; redirect :/, :status => 302 end end end
  35. 35. <Demo>
  36. 36. To Do • Commands parser - Ragel? • OAuth or http://xmppid.net/ • TokyoCabinet • XMPP Component - http://github.com/julien51/babylon • Real PubSub?
  37. 37. Conclusion • XMPP - good, open protocol • xmpp4r-simple - good, easy to use • eventmachine - good network library • sequel - good ORM • ramaze - good web apps framework
  38. 38. Questions?
  39. 39. </stream:stream>

×