forked from pubnub/python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsubscribe.py
More file actions
38 lines (23 loc) · 773 Bytes
/
Copy pathsubscribe.py
File metadata and controls
38 lines (23 loc) · 773 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# PubNub HereNow usage example
import sys
import time
sys.path.append("../../")
from pubnub.callbacks import SubscribeCallback
from pubnub.pnconfiguration import PNConfiguration
from pubnub.pubnub_twisted import PubNubTwisted
pnconf = PNConfiguration()
pnconf.publish_key = "demo"
pnconf.subscribe_key = "demo"
pnconf.enable_subscribe = True
pubnub = PubNubTwisted(pnconf)
class MyListener(SubscribeCallback):
def status(self, pubnub, status):
print("status changed: %s" % status)
def message(self, pubnub, message):
print("new message: %s" % message)
def presence(self, pubnub, presence):
pass
my_listener = MyListener()
pubnub.add_listener(my_listener)
pubnub.subscribe().channels('my_channel').execute()
time.sleep(60)