diff options
Diffstat (limited to 'python-twisted')
| -rw-r--r-- | python-twisted/examples/history.py | 5 | ||||
| -rw-r--r-- | python-twisted/examples/publish.py | 5 | ||||
| -rw-r--r-- | python-twisted/examples/subscribe.py | 11 | 
3 files changed, 13 insertions, 8 deletions
| diff --git a/python-twisted/examples/history.py b/python-twisted/examples/history.py index 10e86b3..81974ec 100644 --- a/python-twisted/examples/history.py +++ b/python-twisted/examples/history.py @@ -20,13 +20,14 @@ ssl_on = len(sys.argv) > 5 and bool(sys.argv[5]) or False  ## -----------------------------------------------------------------------  pubnub = Pubnub(publish_key=publish_key, subscribe_key=subscribe_key,                  secret_key=secret_key, cipher_key=cipher_key, ssl_on=ssl_on) -channel  = 'a' +channel = 'a'  # Asynchronous usage +  def callback(message):      print(message) -pubnub.history(channel, count=2 , callback=callback, error=callback) +pubnub.history(channel, count=2, callback=callback, error=callback)  pubnub.start() diff --git a/python-twisted/examples/publish.py b/python-twisted/examples/publish.py index f7b746f..13b5357 100644 --- a/python-twisted/examples/publish.py +++ b/python-twisted/examples/publish.py @@ -20,11 +20,12 @@ ssl_on = len(sys.argv) > 5 and bool(sys.argv[5]) or False  ## -----------------------------------------------------------------------  pubnub = Pubnub(publish_key=publish_key, subscribe_key=subscribe_key,                  secret_key=secret_key, cipher_key=cipher_key, ssl_on=ssl_on) -channel  = 'hello_world' -message  = 'Hello World !!!' +channel = 'hello_world' +message = 'Hello World !!!'  # Asynchronous usage +  def callback(message):      print(message) diff --git a/python-twisted/examples/subscribe.py b/python-twisted/examples/subscribe.py index 1462a69..9c73439 100644 --- a/python-twisted/examples/subscribe.py +++ b/python-twisted/examples/subscribe.py @@ -21,28 +21,31 @@ ssl_on = len(sys.argv) > 5 and bool(sys.argv[5]) or False  pubnub = Pubnub(publish_key=publish_key, subscribe_key=subscribe_key,                  secret_key=secret_key, cipher_key=cipher_key, ssl_on=ssl_on) -channel  = 'a' - +channel = 'a'  # Asynchronous usage -  def callback(message, channel):      print(message) +  def error(message):      print("ERROR : " + str(message)) +  def connect(message):      print("CONNECTED") +  def reconnect(message):      print("RECONNECTED") +  def disconnect(message):      print("DISCONNECTED") -pubnub.subscribe(channel, callback=callback, error=callback, connect=connect, reconnect=reconnect, disconnect=disconnect) +pubnub.subscribe(channel, callback=callback, error=callback, +                 connect=connect, reconnect=reconnect, disconnect=disconnect)  pubnub.start() | 
