Skip to content

Instantly share code, notes, and snippets.

@stephenlb
Forked from ToeJamson/1.c
Last active October 19, 2017 00:36
Show Gist options
  • Save stephenlb/1edeb930d63d2f0d80f5 to your computer and use it in GitHub Desktop.
Save stephenlb/1edeb930d63d2f0d80f5 to your computer and use it in GitHub Desktop.
topic = "user/path/topic"
from Pubnub import Pubnub
def callback(message, channel):
print(message, channel)
pubnub = Pubnub('demo', 'demo')
pubnub.subscribe('my_channel', callback=callback)
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