2. What’s Pub / Sub ?
• Bidirectional communication between server and
clients
• Clients subscribe to channels
• Server or client pushes events to some channels
• Clients are notified in realtime!
7. Faye
Pros
• Built with ! (And Javascript)
• Open Source and self hosted
• Extensible
• Server level hooks
• Globbing (/users/*)
• Great Maintainer (@jcoglan)
Cons
• Les batteries included
12. Faye Hosting
• It’s a Rack system ! I Know this.
• EventMachine, one thread, tons of connections
• In-Memory by default
• Faye engines, e.g faye-redis, for multiple process
architecture
16. Faye Authentication
• JWT based signature, generated by the Rails
Server when allowed
• Inserted into the faye request through a plugin
executing an Ajax Call
• Check at the faye server level
dimelo/faye-authentication
17. Faye Authentication
In a controller app (route /faye/auth):
def auth
if can?(:read, params[:message].try(:channel))
render :json => {signature: Faye::Authentication.sign(params[:message], 'faye
secret')}
else
render :text => "Forbidden", :status => '403'
end
In your JS :
client.addExtension(new FayeAuthentication(client));
18. Faye Authentication
On the faye server (config.ru):
server = Faye::RackAdapter.new mount: '/faye'
server.add_extension Faye::Authentication::ServerExtension.new('faye secret')
run server
19. Faye Presence
• Keep track of several clients per user
• Notify connection / disconnection
• Keep infos about the session (away / available)
22. Dimelo contest!
• Submit a pull request on a 20+ stars ruby Github repository
• Have it merged
• Have a chance to win a Xbox One or a PS4
• http://contest.dimelo.com
• http://jobs.dimelo.com