Last active
December 10, 2015 19:08
-
-
Save jnevelson/4479279 to your computer and use it in GitHub Desktop.
pubnub listener
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PubnubListener | |
def initialize(pubkey, subkey, secretkey) | |
@pubnub = Pubnub.new(pubkey, subkey, secretkey, false) | |
end | |
def listen(channel) | |
@pubnub.subscribe('channel' => channel, 'callback' => lambda { |msg| puts msg }) | |
end | |
def publish(channel, message) | |
@pubnub.publish('channel' => channel, 'message' => message) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment