aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2019-09-30 04:31:13 -0400
committerJesse Luehrs <doy@tozt.net>2019-09-30 04:35:21 -0400
commitf60b266b7c5e37311188a187ff0177d9662992cd (patch)
tree2c980ca961314ac0877d0a96337588215d6138c8 /src
parent7477c36c374f191b3fbdff905f92ebab8049f5e7 (diff)
downloadteleterm-f60b266b7c5e37311188a187ff0177d9662992cd.tar.gz
teleterm-f60b266b7c5e37311188a187ff0177d9662992cd.zip
send a WatchSession message when connecting as a watcher
Diffstat (limited to 'src')
-rw-r--r--src/client.rs6
-rw-r--r--src/cmd/cast.rs1
-rw-r--r--src/cmd/watch.rs7
-rw-r--r--src/protocol.rs2
4 files changed, 10 insertions, 6 deletions
diff --git a/src/client.rs b/src/client.rs
index 7ccc165..a5881e2 100644
--- a/src/client.rs
+++ b/src/client.rs
@@ -93,6 +93,7 @@ pub struct Client {
rsock: ReadSocket,
wsock: WriteSocket,
+ on_connect: Vec<crate::protocol::Message>,
to_send: std::collections::VecDeque<crate::protocol::Message>,
}
@@ -101,6 +102,7 @@ impl Client {
address: &str,
username: &str,
ty: crate::common::ConnectionType,
+ on_connect: &[crate::protocol::Message],
heartbeat_duration: std::time::Duration,
) -> Self {
let heartbeat_timer =
@@ -118,6 +120,7 @@ impl Client {
rsock: ReadSocket::NotConnected,
wsock: WriteSocket::NotConnected,
+ on_connect: on_connect.to_vec(),
to_send: std::collections::VecDeque::new(),
}
}
@@ -185,6 +188,9 @@ impl Client {
.context(Connect),
));
self.to_send.clear();
+ let mut on_connect =
+ self.on_connect.iter().cloned().collect();
+ self.to_send.append(&mut on_connect);
Ok(crate::component_future::Poll::Event(Event::Reconnect))
}
WriteSocket::Connecting(ref mut fut) => match fut.poll() {
diff --git a/src/cmd/cast.rs b/src/cmd/cast.rs
index 6a66a9a..312874a 100644
--- a/src/cmd/cast.rs
+++ b/src/cmd/cast.rs
@@ -74,6 +74,7 @@ impl CastSession {
address,
username,
crate::common::ConnectionType::Casting,
+ &[],
heartbeat_duration,
);
let process =
diff --git a/src/cmd/watch.rs b/src/cmd/watch.rs
index 1798e19..7d47fbe 100644
--- a/src/cmd/watch.rs
+++ b/src/cmd/watch.rs
@@ -81,7 +81,6 @@ fn watch(id: &str) -> Result<()> {
}
struct WatchSession {
- id: String,
client: crate::client::Client,
}
@@ -96,12 +95,10 @@ impl WatchSession {
address,
username,
crate::common::ConnectionType::Watching,
+ &[crate::protocol::Message::watch_session(id)],
heartbeat_duration,
);
- Ok(Self {
- id: id.to_string(),
- client,
- })
+ Ok(Self { client })
}
}
diff --git a/src/protocol.rs b/src/protocol.rs
index 20a3b32..26a34d0 100644
--- a/src/protocol.rs
+++ b/src/protocol.rs
@@ -75,7 +75,7 @@ impl FramedWriter {
pub const PROTO_VERSION: u32 = 1;
-#[derive(Debug)]
+#[derive(Debug, Clone)]
pub enum Message {
StartCasting {
proto_version: u32,