1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// use rumqttd::{Link, LinkTx, Router, RouterConfig};
// use bytes::BytesMut;
// use mqttbytes::v4::Publish;
// use mqttbytes::QoS;
// use std::thread;
// use std::time::Duration;
//
// fn spawn_publisher(mut router_tx: LinkTx, count: u8) {
// thread::sleep(Duration::from_secs(1));
// let mut pkid = 0;
//
// thread::spawn(move || loop {
// let mut o = BytesMut::new();
// for i in 0..count {
// let topic = "hello/world";
// let qos = QoS::AtLeastOnce;
// let payload = vec![1, 2, i];
// pkid += 1;
//
// let mut publish = Publish::new(topic, qos, payload);
// publish.pkid = pkid;
// publish.write(&mut o).unwrap();
// }
//
// router_tx.send_device_data(o).unwrap();
// thread::sleep(Duration::from_secs(10));
// });
// }
//
// fn main() {
// pretty_env_logger::init();
// let max_segment_size = 100 * 1024;
// let max_segment_count = 10;
// let max_connections = 10;
// let config =
// RouterConfig { instant_ack: false, max_segment_size, max_segment_count, max_connections };
//
// let router = Router::new(0, config);
// let link = router.start_with_cluster("localhost:7070", Vec::<(usize, String)>::new());
// let (link_tx, mut link_rx) = Link::new("device@0", link).unwrap();
//
// spawn_publisher(link_tx, 5);
//
// // Receiver
// loop {
// let notification = link_rx.recv().unwrap();
// println!("Received = {:?}", notification);
// }
// }