aboutsummaryrefslogtreecommitdiffstats
path: root/python/3.3/subscribe-example.py
diff options
context:
space:
mode:
authorgcohen2013-10-08 18:43:16 -0700
committergcohen2013-10-08 18:43:16 -0700
commitcb4b18841fa719ce982b06002889831aedd287ac (patch)
tree81bf5d1ee8eb06281bedf80e440a1249cf7781a0 /python/3.3/subscribe-example.py
parentaaca8fb7cd2f6534cd87fc23efc82d2128b05e13 (diff)
parent52c51378b4647911a64c8d4b1c759756d4930d4b (diff)
downloadpubnub-python-cb4b18841fa719ce982b06002889831aedd287ac.tar.bz2
Merge branch 'TR-89.88.56.47.55'
Conflicts: .gitignore
Diffstat (limited to 'python/3.3/subscribe-example.py')
-rwxr-xr-xpython/3.3/subscribe-example.py64
1 files changed, 0 insertions, 64 deletions
diff --git a/python/3.3/subscribe-example.py b/python/3.3/subscribe-example.py
deleted file mode 100755
index e458e2b..0000000
--- a/python/3.3/subscribe-example.py
+++ /dev/null
@@ -1,64 +0,0 @@
-import sys
-import threading
-import time
-import random
-import string
-from Pubnub import Pubnub
-
-## Initiate Class
-pubnub = Pubnub( 'demo', 'demo', None, False )
-
-print("My UUID is: "+pubnub.uuid)
-
-channel = ''.join(random.choice(string.ascii_letters + string.digits) for x in range(20))
-
-## Subscribe Example
-def receive(message) :
- print(message)
- return False
-
-def pres_event(message):
- print(message)
- return False
-
-def subscribe():
- print("Listening for messages on '%s' channel..." % channel)
- pubnub.subscribe({
- 'channel' : channel,
- 'callback' : receive
- })
-
-def presence():
- print("Listening for presence events on '%s' channel..." % channel)
- pubnub.presence({
- 'channel' : channel,
- 'callback' : pres_event
- })
-
-def publish():
- print("Publishing a test message on '%s' channel..." % channel)
- pubnub.publish({
- 'channel' : channel,
- 'message' : { 'text':'foo bar' }
- })
-
-pres_thread = threading.Thread(target=presence)
-pres_thread.daemon=True
-pres_thread.start()
-
-sub_thread = threading.Thread(target=subscribe)
-sub_thread.daemon=True
-sub_thread.start()
-
-time.sleep(3)
-
-publish()
-
-
-print("waiting for subscribes and presence")
-pres_thread.join()
-
-print pubnub.here_now({'channel':channel})
-
-sub_thread.join()
-