aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock1
-rw-r--r--Cargo.toml1
-rw-r--r--src/cmd/cast.rs27
3 files changed, 29 insertions, 0 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 93c919c..2cec18a 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -581,6 +581,7 @@ dependencies = [
"snafu 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-pty-process 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "tokio-signal 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
"twoway 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
diff --git a/Cargo.toml b/Cargo.toml
index 4af5b09..b58e558 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,6 +13,7 @@ mio = "0.6"
snafu = { version = "0.5", features = ["futures-01"] }
tokio = "0.1"
tokio-pty-process = "0.4"
+tokio-signal = "0.2"
twoway = "0.2"
uuid = { version = "0.7", features = ["v4"] }
diff --git a/src/cmd/cast.rs b/src/cmd/cast.rs
index e7f015f..3715ebf 100644
--- a/src/cmd/cast.rs
+++ b/src/cmd/cast.rs
@@ -1,5 +1,6 @@
use futures::future::Future as _;
use futures::stream::Stream as _;
+use snafu::futures01::stream::StreamExt as _;
use snafu::ResultExt as _;
use tokio::io::AsyncWrite as _;
@@ -19,6 +20,9 @@ pub enum Error {
#[snafu(display("communication with server failed: {}", source))]
Client { source: crate::client::Error },
+
+ #[snafu(display("SIGWINCH handler failed: {}", source))]
+ SigWinchHandler { source: std::io::Error },
}
pub type Result<T> = std::result::Result<T, Error>;
@@ -75,6 +79,8 @@ struct CastSession {
client: crate::client::Client,
process: crate::process::Process,
stdout: tokio::io::Stdout,
+ winches:
+ Box<dyn futures::stream::Stream<Item = (), Error = Error> + Send>,
buffer: crate::term::Buffer,
sent_local: usize,
sent_remote: usize,
@@ -97,10 +103,17 @@ impl CastSession {
);
let process =
crate::process::Process::new(cmd, args).context(Spawn)?;
+ let winches = tokio_signal::unix::Signal::new(
+ tokio_signal::unix::libc::SIGWINCH,
+ )
+ .flatten_stream()
+ .map(|_| ())
+ .context(SigWinchHandler);
Ok(Self {
client,
process,
stdout: tokio::io::stdout(),
+ winches: Box::new(winches),
buffer: crate::term::Buffer::new(),
sent_local: 0,
sent_remote: 0,
@@ -128,6 +141,7 @@ impl CastSession {
&Self::poll_write_terminal,
&Self::poll_flush_terminal,
&Self::poll_write_server,
+ &Self::poll_sigwinch,
];
// this should never return Err, because we don't want server
@@ -253,6 +267,19 @@ impl CastSession {
Ok(crate::component_future::Poll::DidWork)
}
+
+ fn poll_sigwinch(&mut self) -> Result<crate::component_future::Poll<()>> {
+ match self.winches.poll()? {
+ futures::Async::Ready(Some(_)) => {
+ // TODO
+ Ok(crate::component_future::Poll::DidWork)
+ }
+ futures::Async::Ready(None) => unreachable!(),
+ futures::Async::NotReady => {
+ Ok(crate::component_future::Poll::NotReady)
+ }
+ }
+ }
}
#[must_use = "futures do nothing unless polled"]