Module: Sinatra::PubSub::Helpers
- Extended by:
- Helpers
- Included in:
- Sinatra::PubSub, Helpers
- Defined in:
- lib/sinatra/pubsub/helpers.rb
Instance Method Summary collapse
Instance Method Details
#publish(channel, message) ⇒ Object
6 7 8 |
# File 'lib/sinatra/pubsub/helpers.rb', line 6 def publish(channel, ) Redis.publish(channel, .to_json) end |
#publish_all(message) ⇒ Object
10 11 12 |
# File 'lib/sinatra/pubsub/helpers.rb', line 10 def publish_all() publish(:all, ) end |
#subscribe ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/sinatra/pubsub/helpers.rb', line 14 def subscribe Thread.abort_on_exception = true trap('TERM') do Stream.disable! Process.kill('INT', $$) end EM::next_tick do Thread.new do Redis.subscribe end end end |