Skip to content

Instantly share code, notes, and snippets.

@adamvr
Created December 22, 2010 04:18
Show Gist options
  • Save adamvr/751088 to your computer and use it in GitHub Desktop.
Save adamvr/751088 to your computer and use it in GitHub Desktop.
Skeleton code for libmosquitto-py
import mosquitto
def on_connect(rc):
if rc == 0:
print "Connected"
def on_message(msg):
# Do something
print msg.topic
print msg.payload
mq = mosquitto.Mosquitto("client")
mq.on_message = on_message
mq.on_connect = on_connect
mq.connect("red.act.ted")
mq.subscribe("cam/image")
while mq.loop() == 0:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment