Push with Cappuccino and Tornado

Elias Klughammer has taken the time to put together a demo of using the new Tornado web server to bring push to Cappuccino applications. Tornado is a brand new non-blocking server recently open sourced by Facebook which was built to deal with the high intensity demands of FriendFeed. When combined with Cappuccino, the results are pretty impressive:

Check out the project on GitHub to start hacking on your own real time Cappuccino services!

  • Luca Bonifazi
    I've tried async_sinatra on a rails metal class instead of Tornado and without juggernaut.
    It worked, not well coded, just a proof of concept.
    Some work to do on AppController.j for the cappuccino app, just json messages parsing and connection urls.

    Here's the metal code

    require 'sinatra/async'
    #thread safe notificator
    class Looper
    include EM::Deferrable
    def initialize
    @waiters = EM::Queue.new
    end
    def add_listener(listener)
    @waiters.push(listener)
    end
    def notify(x)
    res = x.to_json
    @waiters.size().times do
    @waiters.pop{ |w|
    w.body res
    }
    end
    end
    end

    class SinatraTest < Sinatra::Base
    register Sinatra::Async
    enable :show_exceptions
    @@df = Looper.new
    @@df.callback {|x|
    @@df.notify(x)
    }
    def self.restart_looper
    @@df = Looper.new
    @@df.callback {|x|
    @@df.notify(x)
    }
    end
    apost '/message' do
    message={:type => params["type"],:sender => params["sender"],:body => params["body"]}
    body ""
    @@df.set_deferred_status :succeeded, message
    SinatraTest.restart_looper
    end
    apost '/color' do
    color = {:type => params["type"],:color => params["color"]}
    body ""
    @@df.set_deferred_status :succeeded, color
    SinatraTest.restart_looper
    end
    apost '/updates' do
    @@df.add_listener(self)
    end
    end
  • Luca Bonifazi
    It needs thin for async.
    script/server thin
  • pabloponsbordes
    This is amazing, congratulation for your work it looks really great.
    I will make some experiment with it.
  • Very cool, Elias!
blog comments powered by Disqus

Download

Cappuccino and Objective-J are licensed under the LGPL. For more information, see our licensing page.

Copyright © 2009 - 280 North, Inc. Cappuccino and Objective-J are registered Trademarks of 280 North. Logo by Sofa. Hosting by Slicehost.