Sha256: c5de818ab3aaad39d4930647d6ad79d8b3914cf864235fe874a24d96ef273f1a

Contents?: true

Size: 1.79 KB

Versions: 7

Compression:

Stored size: 1.79 KB

Contents

Pubnub - http://github/pubnub/pubnub-api
@poptartinc on Twitter, @poptart on Github

## ------------------------------------------
## PubNub 3.1 Real-time Cloud Push API - RUBY
## ------------------------------------------
##
## www.pubnub.com - PubNub Real-time Push Service in the Cloud. 
## http://www.pubnub.com/blog/ruby-push-api
##
## PubNub is a Massively Scalable Real-time Service for Web and Mobile Games.
## This is a cloud-based service for broadcasting Real-time messages
## to thousands of web and mobile clients simultaneously.

## -------------
## Ruby Push API
## -------------
pubnub = Pubnub.new(
    "demo",  ## PUBLISH_KEY
    "demo",  ## SUBSCRIBE_KEY
    "demo",  ## SECRET_KEY
    "demo",  ## CIPHER_KEY
    false    ## SSL_ON?
)

# -------
# PUBLISH STRING MESSAGE
# -------
# Send Message
info = pubnub.publish({
    'channel' => 'hello_world',
    'message' => 'hey what is up?'
})
puts(info)

# -------
# PUBLISH ARRAY OF MESSAGES
# -------
# Send Message
info = pubnub.publish({
    'channel' => 'hello_world',
    'message' => { ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"] }
})
puts(info)

# -------
# PUBLISH OBJECT OF STRING MESSAGE
# -------
# Send Message
info = pubnub.publish({
    'channel' => 'hello_world',
    'message' => { 'text' => 'some text data' }
})
puts(info)

# ---------
# SUBSCRIBE
# ---------
# Listen for Messages *NON-BLOCKING*
pubnub.subscribe({
    'channel'  => 'hello_world',
    'callback' => lambda do |message|
        puts(message) ## print message
        return true   ## keep listening?
    end
})

# -------
# HISTORY
# -------
# Load Previously Published Messages
messages = pubnub.history({
    'channel' => 'hello_world',
    'limit'   => 10
})
puts(messages)

# -------
# UUID
# -------
# Generate UUID
uuid = pubnub.UUID()
puts(uuid)

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
pubnub-0.1.10 README
pubnub-0.1.9 README
pubnub-0.1.8 README
pubnub-0.1.7 README
pubnub-0.1.5 README
pubnub-0.1.4 README
pubnub-0.1.2 README