aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDevendra2014-06-17 00:58:40 +0530
committerDevendra2014-06-17 00:58:40 +0530
commit30202de8be4ba24f4fba8dda4b3f28f6ee6600aa (patch)
tree1a7933ad65111c1f19f99c716f9cdd0dfa379f2d
parent819dbedf0904b81e866ea6d27219608167d8b8ca (diff)
downloadpubnub-python-30202de8be4ba24f4fba8dda4b3f28f6ee6600aa.tar.bz2
readme changes
-rw-r--r--python-tornado/README92
-rw-r--r--python-twisted/README98
-rw-r--r--python/README.md119
-rwxr-xr-xpython/examples/dev-console.py2
4 files changed, 130 insertions, 181 deletions
diff --git a/python-tornado/README b/python-tornado/README
index d6eeebe..e046c6b 100644
--- a/python-tornado/README
+++ b/python-tornado/README
@@ -6,7 +6,7 @@
## ----------------------------------------------------
## ----------------------------------------------------
-## PubNub 3.1 Real-time Cloud Push API - PYTHON TORNADO
+## PubNub 3.5.0 Real-time Cloud Push API - PYTHON TORNADO
## ----------------------------------------------------
##
## www.pubnub.com - PubNub Real-time Push Service in the Cloud.
@@ -16,93 +16,63 @@
## This is a cloud-based service for broadcasting Real-time messages
## to thousands of web and mobile clients simultaneously.
-## ----------------------------------------------------
-## Third Party Libraries Dependency
-## ----------------------------------------------------
-## You must download and install,
-##
-## 1. pyopenssl
-## Download from https://launchpad.net/pyopenssl
-##
-## 2. pycrypto
-## Download from https://github.com/dlitz/pycrypto OR
-## from http://code.google.com/p/uploadprj/downloads/detail?name=pycrypto-2.3.win32-py2.7.zip&can=2&q
+
+from Pubnub import PubnubTornado as Pubnub
## ---------------
## Python Push API
## ---------------
-pubnub = Pubnub(
- "demo", ## PUBLISH_KEY
- "demo", ## SUBSCRIBE_KEY
- "demo", ## SECRET_KEY
- "", ## CIPHER_KEY (Cipher key is Optional)
- False ## SSL_ON?
-)
+pubnub = Pubnub(publish_key="demo", subscribe_key="demo", ssl_on=False)
## -----------------------------------------------------------------------
## IO Event Loop
## -----------------------------------------------------------------------
## VERY IMPORTANT TO ADD THIS LINE AT THE VERY BOTTOM!
##
-## tornado.ioloop.IOLoop.instance().start() ## IMPORTANT!
+## pubnub.start() ## IMPORTANT!
##
## -----------------------------------------------------------------------
## Subscribe Example
## -----------------------------------------------------------------------
-def connected() :
- ## -----------------------------------------------------------------------
- ## Publish Example
- ## -----------------------------------------------------------------------
- def publish_complete(info):
- print(info)
-
- pubnub.publish({
- 'channel' : "my-tornado-channel",
- 'message' : {
- 'some_text' : 'Hello World!'
- },
- 'callback' : publish_complete
- })
-
-def message_received(message):
+channel = 'hello_world'
+
+def callback(message, channel):
print(message)
-pubnub.subscribe({
- 'channel' : "my-tornado-channel",
- 'connect' : connected,
- 'callback' : message_received
-})
-## -----------------------------------------------------------------------
-## Time Example
-## -----------------------------------------------------------------------
-def time_complete(timestamp):
- print(timestamp)
+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.time({ 'callback' : time_complete })
## -----------------------------------------------------------------------
## History Example
## -----------------------------------------------------------------------
-def history_complete(messages):
- print(messages)
+def callback(message):
+ print(message)
+
+pubnub.history(channel, count=2, callback=callback, error=callback)
-pubnub.history( {
- 'channel' : "my-tornado-channel",
- 'limit' : 10,
- 'callback' : history_complete
-})
-## -----------------------------------------------------------------------
-## UUID Example
-## -----------------------------------------------------------------------
-uuid = pubnub.uuid()
-print "UUID"
-print uuid
## -----------------------------------------------------------------------
## IO Event Loop
## -----------------------------------------------------------------------
-tornado.ioloop.IOLoop.instance().start()
+pubnub.start()
diff --git a/python-twisted/README b/python-twisted/README
index 5f9b350..402fb34 100644
--- a/python-twisted/README
+++ b/python-twisted/README
@@ -16,103 +16,63 @@
## This is a cloud-based service for broadcasting Real-time messages
## to thousands of web and mobile clients simultaneously.
-## ----------------------------------------------------
-## Python Twisted Setup
-## ----------------------------------------------------
-## Download BZ2 archive from http://twistedmatrix.com/
-##
-## > tar xvfj Twisted-12.1.0.tar.bz2
-## > cd Twisted-12.1.0
-## > sudo python setup.py install
-##
-## ----------------------------------------------------
-## Third Party Libraries Dependency
-## ----------------------------------------------------
-## You must download and install,
-##
-## 1. pyopenssl
-## Download from https://launchpad.net/pyopenssl
-##
-## 2. pycrypto
-## Download from https://github.com/dlitz/pycrypto OR
-## from http://code.google.com/p/uploadprj/downloads/detail?name=pycrypto-2.3.win32-py2.7.zip&can=2&q
+from Pubnub import PubnubTwisted as Pubnub
## ---------------
## Python Push API
## ---------------
-pubnub = Pubnub(
- "demo", ## PUBLISH_KEY
- "demo", ## SUBSCRIBE_KEY
- "demo", ## SECRET_KEY
- "", ## CIPHER_KEY (Cipher key is Optional)
- False ## SSL_ON?
-)
+pubnub = Pubnub(publish_key="demo", subscribe_key="demo", ssl_on=False)
## -----------------------------------------------------------------------
## IO Event Loop
## -----------------------------------------------------------------------
## VERY IMPORTANT TO ADD THIS LINE AT THE VERY BOTTOM!
##
-## reactor.run() ## IMPORTANT!
+## pubnub.start() ## IMPORTANT!
##
## -----------------------------------------------------------------------
## Subscribe Example
## -----------------------------------------------------------------------
-def connected() :
- ## -----------------------------------------------------------------------
- ## Publish Example
- ## -----------------------------------------------------------------------
- def publish_complete(info):
- print(info)
-
- pubnub.publish({
- 'channel' : "my-twisted-channel",
- 'message' : {
- 'some_text' : 'Hello World!'
- },
- 'callback' : publish_complete
- })
-
-def message_received(message):
+channel = 'hello_world'
+
+def callback(message, channel):
print(message)
-pubnub.subscribe({
- 'channel' : "my-twisted-channel",
- 'connect' : connected,
- 'callback' : message_received
-})
-## -----------------------------------------------------------------------
-## Time Example
-## -----------------------------------------------------------------------
-def time_complete(timestamp):
- print(timestamp)
+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.time({ 'callback' : time_complete })
## -----------------------------------------------------------------------
## History Example
## -----------------------------------------------------------------------
-def history_complete(messages):
- print(messages)
+def callback(message):
+ print(message)
+
+pubnub.history(channel, count=2, callback=callback, error=callback)
-pubnub.history( {
- 'channel' : "my-twisted-channel",
- 'limit' : 10,
- 'callback' : history_complete
-})
-## -----------------------------------------------------------------------
-## UUID Example
-## -----------------------------------------------------------------------
-uuid = pubnub.uuid()
-print "UUID"
-print uuid
## -----------------------------------------------------------------------
## IO Event Loop
## -----------------------------------------------------------------------
-reactor.run()
+pubnub.start()
diff --git a/python/README.md b/python/README.md
index 7232756..14d767f 100644
--- a/python/README.md
+++ b/python/README.md
@@ -6,55 +6,78 @@
#### Init
```
-pubnub = Pubnub(
- "demo", ## PUBLISH_KEY
- "demo", ## SUBSCRIBE_KEY
- None, ## SECRET_KEY
- False ## SSL_ON?
-)
+pubnub = Pubnub(publish_key="demo", subscribe_key="demo", ssl_on=False)
+
```
#### PUBLISH
```
-info = pubnub.publish({
- 'channel' : 'hello_world',
- 'message' : {
- 'some_text' : 'Hello my World'
- }
-})
-print(info)
+channel = 'hello_world'
+message = 'Hello World !!!'
+
+# 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
```
-# Listen for Messages *BLOCKING*
-def receive(message) :
+# Listen for Messages
+
+channel = 'hello_world'
+
+def callback(message, channel):
print(message)
- return True
-pubnub.subscribe({
- 'channel' : 'hello_world',
- 'callback' : receive
-})
+
+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)
```
#### PRESENCE
```
-# Listen for Presence Event Messages *BLOCKING*
+# Listen for Presence Event Messages
+
+channel = 'hello_world'
-def pres_event(message) :
+def callback(message, channel):
print(message)
- return True
-pubnub.presence({
- 'channel' : 'hello_world',
- 'callback' : receive
-})
+
+def error(message):
+ print("ERROR : " + str(message))
+
+
+
+pubnub.presence(channel, callback=callback, error=callback)
```
#### HERE_NOW
@@ -62,36 +85,32 @@ pubnub.presence({
```
# Get info on who is here right now!
-here_now = pubnub.here_now({
- 'channel' : 'hello_world',
-})
+channel = 'hello_world'
-print(here_now['occupancy'])
-print(here_now['uuids'])
-```
+# Synchronous usage
+print pubnub.here_now(channel)
-#### Channel Analytics
-```
-analytics = pubnub.analytics({
- 'channel' : 'channel-name-here', ## Leave blank for all channels
- 'limit' : 100, ## aggregation range
- 'ago' : 0, ## minutes ago to look backward
- 'duration' : 100 ## minutes offset
-})
-print(analytics)
+# Asynchronous usage
+def callback(message):
+ print(message)
+
+pubnub.here_now(channel, callback=callback, error=callback)
```
#### HISTORY
```
-# Load Previously Published Messages
-history = pubnub.detailedHistory({
- 'channel' : 'my_channel',
- 'end' : my_end_time_token, # Optional
- 'start' : my_start_time_token, # Optional
- 'count' : num_of_msgs_to_return # Optional, default is 100
-})
-print(history)
+# Synchronous usage
+
+print pubnub.history(channel, count=2)
+
+# Asynchronous usage
+
+
+def callback(message):
+ print(message)
+
+pubnub.history(channel, count=2, callback=callback, error=callback)
```
diff --git a/python/examples/dev-console.py b/python/examples/dev-console.py
index 5bdbe8c..134d2e7 100755
--- a/python/examples/dev-console.py
+++ b/python/examples/dev-console.py
@@ -6,7 +6,7 @@
## http://www.pubnub.com/
import sys
-from Pubnub import PubnubAsync as Pubnub
+from Pubnub import Pubnub
from optparse import OptionParser