diff options
author | Jesse Luehrs <doy@tozt.net> | 2019-11-21 07:23:17 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2019-11-21 07:23:17 -0500 |
commit | 0a7e0122fac5e3c4c0d35c52dea572cc099864ad (patch) | |
tree | 223fdaf48e447caa2f223db27cb556c8c60d0c91 /teleterm/src/client.rs | |
parent | 4b4cad4f9c73e0f4ec6aa8e0242b4377fa995d82 (diff) | |
download | teleterm-0a7e0122fac5e3c4c0d35c52dea572cc099864ad.tar.gz teleterm-0a7e0122fac5e3c4c0d35c52dea572cc099864ad.zip |
move extracting term type out of the client
so that we can use the client outside of a direct terminal context
Diffstat (limited to 'teleterm/src/client.rs')
-rw-r--r-- | teleterm/src/client.rs | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/teleterm/src/client.rs b/teleterm/src/client.rs index daabf7d..248433b 100644 --- a/teleterm/src/client.rs +++ b/teleterm/src/client.rs @@ -97,10 +97,12 @@ impl<S: tokio::io::AsyncRead + tokio::io::AsyncWrite + Send + 'static> Client<S> { pub fn stream( + term_type: &str, connect: Connector<S>, auth: &crate::protocol::Auth, ) -> Self { Self::new( + term_type, connect, auth, &[crate::protocol::Message::start_streaming()], @@ -108,28 +110,33 @@ impl<S: tokio::io::AsyncRead + tokio::io::AsyncWrite + Send + 'static> } pub fn watch( + term_type: &str, connect: Connector<S>, auth: &crate::protocol::Auth, id: &str, ) -> Self { Self::new( + term_type, connect, auth, &[crate::protocol::Message::start_watching(id)], ) } - pub fn list(connect: Connector<S>, auth: &crate::protocol::Auth) -> Self { - Self::new(connect, auth, &[]) + pub fn list( + term_type: &str, + connect: Connector<S>, + auth: &crate::protocol::Auth, + ) -> Self { + Self::new(term_type, connect, auth, &[]) } fn new( + term_type: &str, connect: Connector<S>, auth: &crate::protocol::Auth, on_login: &[crate::protocol::Message], ) -> Self { - let term_type = - std::env::var("TERM").unwrap_or_else(|_| "".to_string()); let heartbeat_timer = tokio::timer::Interval::new_interval(HEARTBEAT_DURATION); @@ -137,7 +144,7 @@ impl<S: tokio::io::AsyncRead + tokio::io::AsyncWrite + Send + 'static> connect, auth: auth.clone(), - term_type, + term_type: term_type.to_string(), heartbeat_timer, reconnect_timer: None, |