ruby on rails - How to subscribe a Pubnub channel asynchronous? -


I want my rail app to subscribe to a global channel, so everything happens on the client, Will be published in I want it to be asynchronous because there will be a lot of messages through that channel, and I want to run it with the rail process. Currently, I can not get it to work, I can call it the initializers / pubnub Rb is inserted:

  $ pubnub.subscribe (channel: 'global', callback: -> (envelope) {do_something})  

I do not get any incoming messages.

Just one usage example in my test app:

  $ pubnub = Pubnub.new (: subscribe_key = & gt; "demo" ,: publish_key => demo ",: heartbeat => 10,: logger = & gt; Rails.logger) ActiveRecord :: base.establish_connection $ pubnub .subscribe (: channel = & gt;: demo) {| e | Message.create (: content => e.msg)}  

This works just fine. Trying to run the code in the callback?


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -