// This example sketch connects to shiftr.io // and sends a message on every keystroke. // // After starting the sketch you can find the // client here: https://shiftr.io/try. // // Note: If you're running the sketch via the // Android Mode you need to set the INTERNET // permission in Android > Sketch Permissions. // // by Joël Gähwiler // https://github.com/256dpi/processing-mqtt import mqtt.*; MQTTClient client; Table table; void setup() { client = new MQTTClient(this); client.connect("mqtt://try:try@broker.shiftr.io", "processing"); client.subscribe("p11/dst"); table = new Table(); table.addColumn("time"); table.addColumn("dst"); } void draw() { } void keyPressed() { client.publish("/hello", "world"); } void messageReceived(String topic, byte[] payload) { println("new message: " + topic + " - " + new String(payload)); String str = new String(payload); int dst = Integer.parseInt(str); TableRow newRow = table.addRow(); newRow.setInt("time", millis()); newRow.setInt("dst", dst); saveTable(table, "data/new.csv"); }