Closed rvgulinski closed 3 years ago
Ok I was finally able to figure it out. I had to spawn another tokio task in the loop inside of the handle_request.
async fn handle_request(
mut request: Request<RecvStream>,
mut respond: SendResponse<Bytes>,
) -> Result<(), Box<dyn Error + Send + Sync>> {
...
loop {
...
let mut send_pushed = respond
.push_request(pushed_req)
.unwrap()
.send_response(pushed_rsp, false)
.unwrap();
tokio::spawn(async move {
send_pushed.send_data(Bytes::from_static(b"Pushed data!"), true);
});
...
}
Here is the scenario:
My question is related to the commented part with the
handle_request
call. Is there a way to implement above scenario? I found that pushed messages are actually sent whenhandle_request(request, respond).await;
code block finished.