Usecases for pubnub
• IoT Secure Messaging
• IoT Device Control
• Message Push Notification
• Home Automation Signalling
• Check this for more details https://stackoverflow.com/questions/20843632/what-is-advantage-and-disadvantage-of-using-pubnub-over-amazon-simple-notificati
by ANSHU PANDEY | [email protected]
Navigate to pubnub.com>> signup for an account or login with google
by ANSHU PANDEY | [email protected]
Click on Create NEW APP+
by ANSHU PANDEY | [email protected]
Create App
by ANSHU PANDEY | [email protected]
After Creating app, scroll down to dashboard
by ANSHU PANDEY | [email protected]
Click on your app, you just created, you might see a default keyset, which can be used to connect to PubNub and you can also create you own keyset.
by ANSHU PANDEY | [email protected]
Click on New keyset to create a keyset
by ANSHU PANDEY | [email protected]
You should be able to get three keys which can be used to connect pubnubAllow pubnub Blocks as shown in below snapshot
by ANSHU PANDEY | [email protected]
Navigate to Blocks option from Left Menu & create a block
by ANSHU PANDEY | [email protected]
Click on create to create event handlers
by ANSHU PANDEY | [email protected]
Name you handler, select after presence from second option, provide topic in third option and remember the topic
by ANSHU PANDEY | [email protected]
The block is currently stopped, click on start block to start the block
by ANSHU PANDEY | [email protected]
Once the block is running, now you are all set to communicate via pubnub
by ANSHU PANDEY | [email protected]
Navigate back to keyinfo to get keys
by ANSHU PANDEY | [email protected]
Python code for Configuring PubNub
from pubnub.pnconfiguration import PNConfiguration
from pubnub.pubnub import PubNub, SubscribeListener
from pubnub.enums import PNStatusCategory
pnconfig = PNConfiguration()
pnconfig.publish_key = "pub-c-097ac4e7-23cf-45ee-980f-1775137fdf4e"
pnconfig.subscribe_key = "sub-c-a3cd0700-2bcd-11e7-97de-0619f8945a4f"
pnconfig.secret_key="sec-c-NzJhOGJlZmItNzQ2OC00MmM2LTg3ZjAtNWUxOWE2MjY4NTgx"
pnconfig.uuid="test"
pubnub = PubNub(pnconfig)
by ANSHU PANDEY | [email protected]
Connecting to broker
my_listener = SubscribeListener()
pubnub.add_listener(my_listener)
pubnub.subscribe().channels('mytopic/new').execute()
my_listener.wait_for_connect()
print('connected')
by ANSHU PANDEY | [email protected]
pubnub.publish().channel('mytopic/new').message({'fieldA': 'awesome', 'fieldB': 10}).sync()
result = my_listener.wait_for_message_on('mytopic/new')
print(result.message)
by ANSHU PANDEY | [email protected]
Navigate to debug console from left bottom option
by ANSHU PANDEY | [email protected]
Enter topic name, UUID as test because in program UUID taken is test, dnt put any authorization key
by ANSHU PANDEY | [email protected]
Now send data from pubnub, run your python code, analyse the messages
by ANSHU PANDEY | [email protected]
Explore PubNub
by ANSHU PANDEY | [email protected]
I am Happy to see you on this slide,Now its your turn to do something exciting with this.
With more Expectation Anshu Pandeyhttps://www.linkedin.com/in/anshupandey/
by ANSHU PANDEY | [email protected]