-
-
Save ToeJamson/41dee002eeebe9d1f920 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| topic = "user/path/topic" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from Pubnub import Pubnub | |
| def callback(message, channel): | |
| print(message, channel) | |
| pubnub = Pubnub('demo', 'demo') | |
| pubnub.subscribe('my_channel', callback=callback) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import paho.mqtt.client as mqtt | |
| def on_message(client, userdata, message): | |
| print(msg.topic, str(msg.payload)) | |
| def on_connect(client, userdata, flags, rc): | |
| client.subscribe('my_topic') | |
| client = mqtt.Client() | |
| client.on_message = on_message | |
| client.on_connect = on_connect | |
| client.connect('mqtt.pubnub.com', 1883) | |
| client.loop_forever() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment