Add user PING support (#346)
- Add `share::PingPong`, which can send `Ping`s, and poll for the `Pong` from the peer.
This commit is contained in:
@@ -129,7 +129,7 @@
|
||||
//! [`SendStream`]: ../struct.SendStream.html
|
||||
//! [`TcpListener`]: https://docs.rs/tokio-core/0.1/tokio_core/net/struct.TcpListener.html
|
||||
|
||||
use {SendStream, RecvStream, ReleaseCapacity};
|
||||
use {SendStream, RecvStream, ReleaseCapacity, PingPong};
|
||||
use codec::{Codec, RecvError};
|
||||
use frame::{self, Pseudo, Reason, Settings, StreamId};
|
||||
use proto::{self, Config, Prioritized};
|
||||
@@ -459,6 +459,17 @@ where
|
||||
pub fn graceful_shutdown(&mut self) {
|
||||
self.connection.go_away_gracefully();
|
||||
}
|
||||
|
||||
/// Takes a `PingPong` instance from the connection.
|
||||
///
|
||||
/// # Note
|
||||
///
|
||||
/// This may only be called once. Calling multiple times will return `None`.
|
||||
pub fn ping_pong(&mut self) -> Option<PingPong> {
|
||||
self.connection
|
||||
.take_user_pings()
|
||||
.map(PingPong::new)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, B> futures::Stream for Connection<T, B>
|
||||
|
||||
Reference in New Issue
Block a user