From 30202de8be4ba24f4fba8dda4b3f28f6ee6600aa Mon Sep 17 00:00:00 2001 From: Devendra Date: Tue, 17 Jun 2014 00:58:40 +0530 Subject: readme changes --- python-twisted/README | 98 +++++++++++++++------------------------------------ 1 file changed, 29 insertions(+), 69 deletions(-) (limited to 'python-twisted/README') 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() -- cgit v1.2.3 From c731ae584de53da55ed799f8fd59bff10b9b9b72 Mon Sep 17 00:00:00 2001 From: Devendra Date: Tue, 17 Jun 2014 02:43:16 +0530 Subject: readme changes --- python-twisted/README | 78 --------------------------------------------------- 1 file changed, 78 deletions(-) delete mode 100644 python-twisted/README (limited to 'python-twisted/README') diff --git a/python-twisted/README b/python-twisted/README deleted file mode 100644 index 402fb34..0000000 --- a/python-twisted/README +++ /dev/null @@ -1,78 +0,0 @@ -## --------------------------------------------------- -## -## YOU MUST HAVE A PUBNUB ACCOUNT TO USE THE API. -## http://www.pubnub.com/account -## -## ---------------------------------------------------- - -## ---------------------------------------------------- -## PubNub 3.1 Real-time Cloud Push API - PYTHON TWISTED -## ---------------------------------------------------- -## -## www.pubnub.com - PubNub Real-time Push Service in the Cloud. -## http://github.com/pubnub/pubnub-api/tree/master/python-twisted/ -## -## PubNub is a Massively Scalable Real-time Service for Web and Mobile Games. -## This is a cloud-based service for broadcasting Real-time messages -## to thousands of web and mobile clients simultaneously. - - -from Pubnub import PubnubTwisted as Pubnub - -## --------------- -## Python Push API -## --------------- -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() ## IMPORTANT! -## - -## ----------------------------------------------------------------------- -## 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 -## ----------------------------------------------------------------------- -pubnub.start() -- cgit v1.2.3