Created
December 1, 2011 16:07
-
-
Save ferblape/1417842 to your computer and use it in GitHub Desktop.
Actuable Websockets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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