14 Jul '13, 2pm

Chat Example App Using Server-Sent Events

Chat Example App Using Server-Sent Events Rails 4 can stream data to the browser with ActionController::Live using server-sent events (SSEs) . I was curious how server sent events worked so I decided to use them to implement a simple chat application. Tiny-chat is a chat app I built using Goliath , Redis Pub/Sub and of course server-sent events . Subscribing to Events require 'goliath' require 'redis' class Subscribe < Goliath::API def response(env) EM.synchrony do @redis = Redis.new(Options::redis) channel = env["REQUEST_PATH"].sub(/^\/subscribe\//, '') # We pass the subscribe method a block which describes what to # do when we receive an event. # This block writes the message formatted as a server sent event # to the HTTP stream. @redis.subscribe(channel) do |on| on.message do |channel, message| @message = message env.stream_send(payload) end end end end streaming_respon...

Full article: http://robots.thoughtbot.com/post/55421584115/chat-exampl...

Tweets

These are the positions we're currently recruit...

royalnavy.mod.uk 15 Jul '13, 9am

We would like to place Cookies on your computer to give you the best possible experience when you visit our website. If yo...

Another example of an onboard aircraft fire lin...

ntsb.gov 15 Jul '13, 6pm

The passenger was wearing an Ecoquest Fresh Air Buddy Personal Air Purifier around his neck. According to the manufacturer...

Admin (7) FYI re Birmingham next weekend...

networkwestmidlands.com 14 Jul '13, 11am

This Information is provided by the operators, other roadworks could be affecting services that we have not been informed ...

We Live IN Singapura Version 2

events.insing.com 16 Jul '13, 1am

Celebrate Hossan's 20th anniversary in show business in this one-of-a-kind musical romp! Revisit Singapore's most-loved sh...

Jihadists issue report on recent #Sinai events ...

longwarjournal.org 15 Jul '13, 5pm

On July 14, the individual or group responsible for online statements from al Salafiyya al Jihadiyya in Sinai and Ansar al...