Skip to content

Instantly share code, notes, and snippets.

@ferblape
Created December 1, 2011 16:07
Show Gist options
  • Save ferblape/1417842 to your computer and use it in GitHub Desktop.
Save ferblape/1417842 to your computer and use it in GitHub Desktop.
Actuable Websockets
# Little proof of concept of how to implement a websocket server
# using Redis PubSub capabilities and Cramp (http://cramp.in/)
class ActuableWS < Cramp::Websocket
on_start :create_redis
on_finish :destroy_redis
def create_redis
@sub = EM::Hiredis.connect("redis://localhost:6379")
@sub.subscribe('actuable-realtime')
@sub.on(:message) do |channel, message|
render(message)
end
end
def destroy_redis
@sub.close_connection
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment