diff options
| author | Devendra | 2014-06-18 01:02:15 +0530 | 
|---|---|---|
| committer | Devendra | 2014-06-18 01:02:15 +0530 | 
| commit | a1ee7f8bd90b463318bfa75f7ee4f58d458d2a24 (patch) | |
| tree | 9e260902f960f792a93fa25e3b619c42ecb5f4d4 /python/examples/subscribe-example.py | |
| parent | bfd5c64bdf7ed45f21207cb53c653e7220e39eff (diff) | |
| parent | 083127cde127dd78fc88ffe2b3b82144b2c07038 (diff) | |
| download | pubnub-python-a1ee7f8bd90b463318bfa75f7ee4f58d458d2a24.tar.bz2 | |
Merge branch 'master' into develop
Diffstat (limited to 'python/examples/subscribe-example.py')
| -rwxr-xr-x | python/examples/subscribe-example.py | 65 | 
1 files changed, 0 insertions, 65 deletions
| diff --git a/python/examples/subscribe-example.py b/python/examples/subscribe-example.py deleted file mode 100755 index 14a43d9..0000000 --- a/python/examples/subscribe-example.py +++ /dev/null @@ -1,65 +0,0 @@ -import sys -sys.path.append('../') -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() - | 
