Sha256: e74a99b241558eae9437411097978657ee710db8c2b1cc11bcb83bc97d611006
Contents?: true
Size: 1.66 KB
Versions: 3
Compression:
Stored size: 1.66 KB
Contents
## ----------------------------------- ## PubNub Ruby API Publish Example ## ----------------------------------- ## including required libraries require 'rubygems' require 'pubnub_ruby/pubnub' ## declaring publish_key, subscribe_key, secret_key, cipher_key, channel, ssl flag, messages publish_key = 'demo' subscribe_key = 'demo' secret_key = 'demo' cipher_key = 'demo' ssl_on = false channel = 'hello_world' strMessage = "Hi. (顶顅Ȓ)" arrMessage = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"] objMessage = {"Name"=>"John","Age"=>"23"} ## Print usage if missing info. if !strMessage && arrMessage && objMessage puts(' Get API Keys at http://www.pubnub.com/account ============== EXAMPLE USAGE: ============== ruby publish-example.rb PUB-KEY SUB-KEY SECRET-KEY "message text" SSL-ON ruby publish-example.rb demo demo "demo" "hey what is up?" true ') exit() end ## Pubnub state initialization (INITIALIZATION) puts('Initializing new Pubnub state') pubnub = Pubnub.new(publish_key,subscribe_key,secret_key,cipher_key,ssl_on) ## Send Message (PUBLISH) -- String puts("\nSending message in String format with publish() Function") info = pubnub.publish({ 'channel' => channel, 'message' => strMessage }) puts(info) ## Send Message (PUBLISH) -- Array puts("\nSending message in Array format with publish() Function") info = pubnub.publish({ 'channel' => channel, 'message' => arrMessage }) puts(info) ## Send Message (PUBLISH) -- Object (Dictionary) puts("\nSending message in Dictionary Object format with publish() Function") info = pubnub.publish({ 'channel' => channel, 'message' => objMessage }) puts(info)
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
pubnub-0.1.5 | examples/publish_example.rb |
pubnub-0.1.4 | examples/publish_example.rb |
pubnub-0.1.2 | examples/publish_example.rb |