From c731ae584de53da55ed799f8fd59bff10b9b9b72 Mon Sep 17 00:00:00 2001 From: Devendra Date: Tue, 17 Jun 2014 02:43:16 +0530 Subject: readme changes --- python-tornado/migration.md | 164 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 164 insertions(+) create mode 100644 python-tornado/migration.md (limited to 'python-tornado/migration.md') diff --git a/python-tornado/migration.md b/python-tornado/migration.md new file mode 100644 index 0000000..10d03ae --- /dev/null +++ b/python-tornado/migration.md @@ -0,0 +1,164 @@ +## PubNub 3.5.0 Web Data Push Cloud-hosted API - PYTHON +#### www.pubnub.com - PubNub Web Data Push Service in the Cloud. +#### http://github.com/pubnub/python + + +#### Init + + + +``` + +# Pre 3.5: +# + +# New in 3.5+ +pubnub = Pubnub(publish_key="demo", subscribe_key="demo", ssl_on=False) + +``` + +#### PUBLISH + +``` +channel = 'hello_world' +message = 'Hello World !!!' + +# Pre 3.5: +# + +# New in 3.5+ + +# Synchronous usage +print pubnub.publish(channel='hello_world', message='Hello World !!!') + +# Asynchronous usage + +def callback(message): + print(message) + +pubnub.publish(channel, message, callback=callback, error=callback) + +``` + + +#### SUBSCRIBE +Pre 3.5.x, subscribe was blocking and would only be terminated via a false return from the callback. In our latest version of the SDK, subscribe is asyncronous, and because of this, usage is a bit different, but the experience is more like our other async SDKs. + +``` + +# Listen for Messages + +channel = 'hello_world' + +# Pre 3.5: +# + +# New in 3.5+ + +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) +``` + +#### Unsubscribe +Once subscribed, you can easily, gracefully, unsubscribe: + +``` +# Pre 3.5: +# + +# New in 3.5+ + +Unsub example +``` + +#### PRESENCE + +``` + +# Pre 3.5: +# + +# New in 3.5+ + +# Listen for Presence Event Messages + +channel = 'hello_world' + +def callback(message, channel): + print(message) + + +def error(message): + print("ERROR : " + str(message)) + + + +pubnub.presence(channel, callback=callback, error=callback) +``` + +#### HERE_NOW + +``` + +# Pre 3.5: +# + +# New in 3.5+ + +# Get info on who is here right now! + +channel = 'hello_world' + +# Synchronous usage +print pubnub.here_now(channel) + + +# Asynchronous usage + +def callback(message): + print(message) + +pubnub.here_now(channel, callback=callback, error=callback) +``` + +#### HISTORY + +``` + +# Pre 3.5: +# + +# New in 3.5+ + +# Synchronous usage + +print pubnub.history(channel, count=2) + +# Asynchronous usage + + +def callback(message): + print(message) + +pubnub.history(channel, count=2, callback=callback, error=callback) +``` -- cgit v1.2.3 From c1f366829375593bf3946d5d2a761af57d521783 Mon Sep 17 00:00:00 2001 From: Devendra Date: Tue, 17 Jun 2014 03:15:19 +0530 Subject: adding migration files --- python-tornado/migration.md | 97 +++++++++++++++++++++++++++++++-------------- 1 file changed, 68 insertions(+), 29 deletions(-) (limited to 'python-tornado/migration.md') diff --git a/python-tornado/migration.md b/python-tornado/migration.md index 10d03ae..5ce15b5 100644 --- a/python-tornado/migration.md +++ b/python-tornado/migration.md @@ -2,15 +2,28 @@ #### www.pubnub.com - PubNub Web Data Push Service in the Cloud. #### http://github.com/pubnub/python +#### Import -#### Init +``` +# Pre 3.5: +from Pubnub import Pubnub +# New in 3.5+ +from Pubnub import PubnubTornado as Pubnub + +``` +#### Init + ``` # Pre 3.5: -# +pubnub = Pubnub( + "demo", ## PUBLISH_KEY + "demo", ## SUBSCRIBE_KEY + False ## SSL_ON? +) # New in 3.5+ pubnub = Pubnub(publish_key="demo", subscribe_key="demo", ssl_on=False) @@ -24,14 +37,16 @@ channel = 'hello_world' message = 'Hello World !!!' # Pre 3.5: -# - -# New in 3.5+ +def callback(messages): + print(messages) -# Synchronous usage -print pubnub.publish(channel='hello_world', message='Hello World !!!') +pubnub.history( { + 'channel' : channel, + 'message' : message, + 'callback' : callback +}) -# Asynchronous usage +# New in 3.5+ def callback(message): print(message) @@ -42,7 +57,6 @@ pubnub.publish(channel, message, callback=callback, error=callback) #### SUBSCRIBE -Pre 3.5.x, subscribe was blocking and would only be terminated via a false return from the callback. In our latest version of the SDK, subscribe is asyncronous, and because of this, usage is a bit different, but the experience is more like our other async SDKs. ``` @@ -51,7 +65,17 @@ Pre 3.5.x, subscribe was blocking and would only be terminated via a false retur channel = 'hello_world' # Pre 3.5: -# +def connected() : + print('CONNECTED') + +def message_received(message): + print(message) + +pubnub.subscribe({ + 'channel' : channel, + 'connect' : connected, + 'callback' : message_received +}) # New in 3.5+ @@ -84,11 +108,13 @@ Once subscribed, you can easily, gracefully, unsubscribe: ``` # Pre 3.5: -# +pubnub.unsubscribe({ + 'channel' : 'hello_world' +}) # New in 3.5+ -Unsub example +pubnub.unsubscribe(channel='hello_world') ``` #### PRESENCE @@ -111,8 +137,6 @@ def callback(message, channel): def error(message): print("ERROR : " + str(message)) - - pubnub.presence(channel, callback=callback, error=callback) ``` @@ -120,20 +144,22 @@ pubnub.presence(channel, callback=callback, error=callback) ``` -# Pre 3.5: -# +channel = 'hello_world' -# New in 3.5+ +# Pre 3.5: +def callback(messages): + print(messages) -# Get info on who is here right now! +pubnub.here_now( { + 'channel' : channel, + 'callback' : callback +}) -channel = 'hello_world' -# Synchronous usage -print pubnub.here_now(channel) +# New in 3.5+ +# Get info on who is here right now! -# Asynchronous usage def callback(message): print(message) @@ -144,21 +170,34 @@ pubnub.here_now(channel, callback=callback, error=callback) #### HISTORY ``` +channel = 'hello_world' # Pre 3.5: -# - -# New in 3.5+ +def history_complete(messages): + print(messages) -# Synchronous usage +pubnub.history( { + 'channel' : channel, + 'limit' : 2, + 'callback' : history_complete +}) -print pubnub.history(channel, count=2) - -# Asynchronous usage +# New in 3.5+ def callback(message): print(message) pubnub.history(channel, count=2, callback=callback, error=callback) ``` + +#### IO Event Loop + +``` + +# Pre 3.5: +tornado.ioloop.IOLoop.instance().start() + +# New in 3.5+ +pubnub.start() +``` -- cgit v1.2.3 From 7865970148139babf2921b4d7fe11917568be9e9 Mon Sep 17 00:00:00 2001 From: Devendra Date: Tue, 17 Jun 2014 03:18:40 +0530 Subject: typo --- python-tornado/migration.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'python-tornado/migration.md') diff --git a/python-tornado/migration.md b/python-tornado/migration.md index 5ce15b5..7feb4ea 100644 --- a/python-tornado/migration.md +++ b/python-tornado/migration.md @@ -40,7 +40,7 @@ message = 'Hello World !!!' def callback(messages): print(messages) -pubnub.history( { +pubnub.publish( { 'channel' : channel, 'message' : message, 'callback' : callback -- cgit v1.2.3 From 2ad738eb629128fb822794c385feb47bcf356c44 Mon Sep 17 00:00:00 2001 From: Geremy Cohen Date: Mon, 16 Jun 2014 16:06:34 -0700 Subject: Update migration.md --- python-tornado/migration.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'python-tornado/migration.md') diff --git a/python-tornado/migration.md b/python-tornado/migration.md index 7feb4ea..d5fd8f0 100644 --- a/python-tornado/migration.md +++ b/python-tornado/migration.md @@ -1,6 +1,7 @@ -## PubNub 3.5.0 Web Data Push Cloud-hosted API - PYTHON -#### www.pubnub.com - PubNub Web Data Push Service in the Cloud. -#### http://github.com/pubnub/python +## Contact support@pubnub.com for all questions + +#### [PubNub](http://www.pubnub.com) Real-time Data Network +##### Tornado Migration #### Import @@ -201,3 +202,4 @@ tornado.ioloop.IOLoop.instance().start() # New in 3.5+ pubnub.start() ``` +## Contact support@pubnub.com for all questions -- cgit v1.2.3