public boolean receiveMqttMessage(CharSequence topic, ChannelReader payload) { // this received when mosquitto_pub is invoked - see MQTTClient System.out.print("\ningress body: "); // Read the message payload and output it to System.out payload.readUTFOfLength(payload.available(), System.out); System.out.println(); // Create the on-demand mqtt payload writer Writable mqttPayload = writer -> writer.writeUTF("\nsecond step test message"); // On the 'localtest' topic publish the mqtt payload cmd.publishTopic(mqttPayload, WaitFor.None); // We consumed the message return true; } }
if (length>0) { out.append(" with body of "); reader.readUTFOfLength(length,out);
if (length>0) { out.append(" with body of "); reader.readUTFOfLength(length,out);
if (length>0) { out.append(" with body of "); reader.readUTFOfLength(length,out);
@Override public boolean restRequest(HTTPRequestReader request) { if (request.isVerbPost()) { request.openPayloadData((reader)->{ console.append("POST: "); reader.readUTFOfLength(reader.available(),console); }); } //if this can not be published then we will get the request again later to be reattempted. return cmd.publishHTTPResponse(request, 200, false, HTTPContentTypeDefaults.TXT, (writer)-> { writer.writeUTF8Text("beginning of text file\n"); }); }
@Override public boolean restRequest(HTTPRequestReader request) { if (request.isVerbPost()) { request.openPayloadData((reader)->{ console.append("POST: "); reader.readUTFOfLength(reader.available(),console); }); } //if this can not be published then we will get the request again later to be reattempted. return cmd.publishHTTPResponse(request, 200, false, HTTPContentTypeDefaults.TXT, (writer)-> { renderer.render(writer, this); }); }
@Override public boolean restRequest(HTTPRequestReader request) { int argInt = request.structured().readInt(nameFieldId); Appendables.appendValue(console, "Arg Int: ", argInt, "\n"); request.structured().identityVisit(HTTPHeaderDefaults.COOKIE, (id,reader,field)-> { console.append("COOKIE: "); reader.readUTF(console).append('\n'); }); if (request.isVerbPost()) { request.openPayloadData((reader)->{ console.append("POST: "); reader.readUTFOfLength(reader.available(), console); console.append('\n'); }); } //no body just a 200 ok response. return cmd.publishHTTPResponse(request, 200); }
reader.readUTFOfLength(reader.available(),console); console.append('\n');
reader.readUTFOfLength(reader.available(),console); console.append('\n');
reader.readUTFOfLength(reader.available(), console); console.append('\n');