Skip to content

Instantly share code, notes, and snippets.

@ToeJamson
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ToeJamson/41dee002eeebe9d1f920 to your computer and use it in GitHub Desktop.
Save ToeJamson/41dee002eeebe9d1f920 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