-
-
Save stephenlb/1edeb930d63d2f0d80f5 to your computer and use it in GitHub Desktop.
This file contains 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 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 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