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/README.md | 61 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 python-tornado/README.md (limited to 'python-tornado/README.md') diff --git a/python-tornado/README.md b/python-tornado/README.md new file mode 100644 index 0000000..1d210f9 --- /dev/null +++ b/python-tornado/README.md @@ -0,0 +1,61 @@ +## PubNub 3.5.0 Web Data Push Cloud-hosted API - PYTHON TORNADO +#### www.pubnub.com - PubNub Web Data Push Service in the Cloud. +#### http://github.com/pubnub/python + +#### Import +``` +from Pubnub import PubnubTornado as Pubnub +``` + +#### Init +pubnub = Pubnub(publish_key="demo", subscribe_key="demo", ssl_on=False) + + +#### IO Event Loop +##### VERY IMPORTANT TO ADD THIS LINE AT THE VERY BOTTOM! + +``` +pubnub.start() +``` + +#### Subscribe Example +``` +channel = 'hello_world' + +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) +``` + +#### History Example +``` +def callback(message): + print(message) + +pubnub.history(channel, count=2, callback=callback, error=callback) +``` + + +#### IO Event Loop start +``` +pubnub.start() +``` \ No newline at end of file -- cgit v1.2.3