Skip to content

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

README.md

AsyncIO PubNub Subscribe Example

pubnub-asyncio-simple-example

Usage example:

pip install asyncio pubnub
export PUBNUB_PUBLISH_KEY=demo
export PUBNUB_SUBSCRIBE_KEY=demo
python main.py

Output:

Listening for messages...
Connected
Received message: Hello World on channel: my_channel
Received message: Hello World on channel: my_channel
Received message: Hello World on channel: my_channel
Received message: Hello World on channel: my_channel
Received message: Hello World on channel: my_channel

In another terminal:

export PUBNUB_PUBLISH_KEY=demo
export PUBNUB_SUBSCRIBE_KEY=demo
curl "https://h2.pubnubapi.com/publish/${PUBNUB_PUBLISH_KEY}/${PUBNUB_SUBSCRIBE_KEY}/0/my_channel/0/%22Hello%20World%22"

Output:

[1,"Sent","17183967137027574"]