File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -66,8 +66,11 @@ A `DiscoveryHandlerImpl` Struct has been created (in `discovery_handler.rs`) tha
66
66
First, let's add the additional crates we are using to our `Cargo.toml` under dependencies.
67
67
68
68
` ` ` text
69
+ tokio-stream = { version = "0.1", features = ["net"] }
69
70
anyhow = "1.0.38"
70
71
reqwest = "0.10.8"
72
+ env_logger = "0.9.0"
73
+ log = "0.4"
71
74
` ` `
72
75
73
76
Now, import our dependencies and define some constants. Add the following after the other imports at the top of `discovery_handler.rs`.
@@ -94,8 +97,8 @@ impl DiscoveryHandler for DiscoveryHandlerImpl {
94
97
// Get the discovery url from the ` DiscoverRequest`
95
98
let url = request.get_ref().discovery_details.clone();
96
99
// Create a channel for sending and receiving device updates
97
- let (mut stream_sender, stream_receiver) = mpsc::channel(4);
98
- let mut register_sender = self.register_sender.clone();
100
+ let (stream_sender, stream_receiver) = mpsc::channel(4);
101
+ let register_sender = self.register_sender.clone();
99
102
tokio::spawn(async move {
100
103
loop {
101
104
let resp = get(&url).await.unwrap();
@@ -124,7 +127,9 @@ impl DiscoveryHandler for DiscoveryHandlerImpl {
124
127
}
125
128
});
126
129
// Send the agent one end of the channel to receive device updates
127
- Ok(Response::new(stream_receiver))
130
+ Ok(Response::new(tokio_stream::wrappers::ReceiverStream::new(
131
+ stream_receiver,
132
+ )))
128
133
}
129
134
}
130
135
```
You can’t perform that action at this time.
0 commit comments