Sha256: 28119e1d91f1e4f06445e89cc4e46dcc3a73ea20d7f4c84c9e5bb3451d375895
Contents?: true
Size: 1.13 KB
Versions: 3
Compression:
Stored size: 1.13 KB
Contents
## ----------------------------------- ## PubNub Ruby API Subscribe Example ## ----------------------------------- ## including required libraries require 'rubygems' require 'pubnub_ruby/pubnub' ## declaring publish_key, subscribe_key, secret_key, cipher_key, ssl flag publish_key = 'demo' subscribe_key = 'demo' secret_key = 'demo' cipher_key = 'demo' ssl_on = false channel = 'hello_world' ## Print usage if missing info. if !subscribe_key puts(' Get API Keys at http://www.pubnub.com/account ============== EXAMPLE USAGE: ============== ruby subscribe-example.rb PUBLISH-KEY SUBSCRIBE-KEY SSL-ON ruby subscribe-example.rb demo demo true ') exit() end ## Create Pubnub Client API (INITIALIZATION) puts('Initializing new Pubnub state') pubnub = Pubnub.new(publish_key,subscribe_key,secret_key,cipher_key,ssl_on) ## Listen for Messages (SUBSCRIBE) puts('Listening for new messages with subscribe() Function') puts('Press CTRL+C to quit.') pubnub.subscribe({ 'channel' => channel, 'callback' => lambda do |message| puts(message) ## print message return true ## keep listening? end })
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
pubnub-0.1.5 | examples/subscribe_example.rb |
pubnub-0.1.4 | examples/subscribe_example.rb |
pubnub-0.1.2 | examples/subscribe_example.rb |