物联网 MQTT简易版Broker基于Protobuf报文
流程演示
发布者发送: PUBLISH#topic1#hello
↓
Broker 收到消息 (handlePublish)
↓
查找 topic1 的所有订阅者 (PrintWriter 集合)
↓
遍历每个订阅者的 PrintWriter
↓
writer.println("MSG#topic1#hello") ← 你选中的代码
↓
数据写入 Socket 输出流 → 网络传输 → 订阅端 Socket 输入流
↓
订阅端的 in.readLine() 返回这行数据
↓
订阅端收到消息
源码
spring-boot-iot-sample-broker-protobuf[https://gitee.com/kcnf-webrtc/iot-sample/tree/master/spring-boot-iot-sample/spring-boot-iot-sample-broker-protobuf]
spring-boot-iot-protobuf-api[https://gitee.com/kcnf-webrtc/iot-sample/tree/master/spring-boot-iot-sample/spring-boot-iot-protobuf-api]
