Closed paberr closed 5 years ago
Hi,
just noticed this issue by accident. I would like to just inform you that we've recently updated both tungstenite-rs
and tokio-tungstenite
on crates.io, so if you want, you can use the latest version from crates.io
which now have the latest changes and fixes and also the semantics which does seem to suite your needs (i.e. you can receive the Message::Close
and also push it to the sink if needed). Also the Async::Ready(None)
is returned by tokio-tungstenite
's Stream
when the connection is meant to be closed (i.e. when the object can safely be dropped).
Currently, we close our WebSocket connections by:
select
between a one-shot channel and the connection processing future.https://github.com/nimiq/core-rs/blob/52906bda31a837966964d416b8c9c0436b874248/network/src/connection/network_connection.rs#L131-L159
With the most recent version of tungstenite and tokio-tungstenite there might be a nicer way to do it:
I only skimmed over the two pull requests, but it seems that it is now possible to send the close frame via the Sink and shut down the Stream part when receiving the other party's close frame.