From 3a5a980b3c75e6eee176fdc23b63855cee30ceff Mon Sep 17 00:00:00 2001 From: gcohen Date: Mon, 29 Dec 2014 18:20:58 -0800 Subject: initial commit --- python/examples/futureHouse/futureHouse.py | 40 ++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 python/examples/futureHouse/futureHouse.py diff --git a/python/examples/futureHouse/futureHouse.py b/python/examples/futureHouse/futureHouse.py new file mode 100644 index 0000000..55286a2 --- /dev/null +++ b/python/examples/futureHouse/futureHouse.py @@ -0,0 +1,40 @@ +import sys +from Pubnub import Pubnub + +publish_key = len(sys.argv) > 1 and sys.argv[1] or 'demo' +subscribe_key = len(sys.argv) > 2 and sys.argv[2] or 'demo' +secret_key = len(sys.argv) > 3 and sys.argv[3] or 'demo' +cipher_key = len(sys.argv) > 4 and sys.argv[4] or '' +ssl_on = len(sys.argv) > 5 and bool(sys.argv[5]) or False + +## ----------------------------------------------------------------------- +## Initiate Pubnub State +## ----------------------------------------------------------------------- +pubnub = Pubnub(publish_key=publish_key, subscribe_key=subscribe_key, + secret_key=secret_key, cipher_key=cipher_key, ssl_on=ssl_on) + +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, \ No newline at end of file -- cgit v1.2.3