Add SIN.04028 tutorial material, tutor prompt and conversation log
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
bac80295b7
commit
f615bef426
30 files changed
+8123
No files matched your search
+67
@@ -0,0 +1,67 @@
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.eclipse.paho.mqttv5.client.IMqttAsyncClient;
|
||||
import org.eclipse.paho.mqttv5.client.MqttAsyncClient;
|
||||
import org.eclipse.paho.mqttv5.client.persist.MemoryPersistence;
|
||||
import org.eclipse.paho.mqttv5.common.MqttMessage;
|
||||
|
||||
void publish(
|
||||
IMqttAsyncClient client,
|
||||
String topic,
|
||||
String content,
|
||||
int qos,
|
||||
boolean retained)
|
||||
throws Exception {
|
||||
var message = new MqttMessage(
|
||||
content.getBytes(StandardCharsets.UTF_8)
|
||||
);
|
||||
message.setQos(qos);
|
||||
message.setRetained(retained);
|
||||
client.publish(topic, message).waitForCompletion();
|
||||
}
|
||||
|
||||
void main(String[] arguments) throws Exception {
|
||||
var consoleInUnit = arguments.length > 0 ? arguments[0] : "alice";
|
||||
var rot13Unit = arguments.length > 1 ? arguments[1] : "alice";
|
||||
var consoleOutUnit = arguments.length > 2 ? arguments[2] : "alice";
|
||||
var broker = System.getProperty("mqtt.broker", "tcp://localhost:1883");
|
||||
var client = new MqttAsyncClient(
|
||||
broker,
|
||||
"configure-" + UUID.randomUUID(),
|
||||
new MemoryPersistence()
|
||||
);
|
||||
|
||||
client.connect().waitForCompletion();
|
||||
|
||||
var rot13Intent = """
|
||||
subscribe:
|
||||
topic: Tutorial/ConsoleIn/U/%s/E/text
|
||||
""".formatted(consoleInUnit);
|
||||
|
||||
var consoleOutIntent = """
|
||||
subscribe:
|
||||
topic: Tutorial/ROT13/U/%s/E/crypted
|
||||
""".formatted(rot13Unit);
|
||||
|
||||
publish(
|
||||
client,
|
||||
"Tutorial/ROT13/U/" + rot13Unit + "/I",
|
||||
rot13Intent,
|
||||
1,
|
||||
false
|
||||
);
|
||||
|
||||
publish(
|
||||
client,
|
||||
"Tutorial/ConsoleOut/U/" + consoleOutUnit + "/I",
|
||||
consoleOutIntent,
|
||||
1,
|
||||
false
|
||||
);
|
||||
|
||||
client.disconnect().waitForCompletion();
|
||||
client.close();
|
||||
|
||||
IO.println("Wired: ConsoleIn -> ROT13 -> ConsoleOut");
|
||||
}
|
||||
Reference in new issue
Block a user