ruby on rails - How to subscribe a Pubnub channel asynchronous? -
i want rails app subscribe global channel, happens on client, client publish channel. want asynchronous because there lot of messages via channels, , want run along rails process. currently, can't work, set initializers/pubnub.rb
:
$pubnub.subscribe(channel: 'global', callback: ->(envelop) { do_something })
i don't incoming messages.
just usage illustration in test app:
$pubnub = pubnub.new( :subscribe_key => "demo", :publish_key => "demo", :heartbeat => 10, :logger => rails.logger ) activerecord::base.establish_connection $pubnub.subscribe(:channel => :demo){|e| message.create(:content => e.msg)}
it works fine. code trying run in callback?
ruby-on-rails pubnub
No comments:
Post a Comment