From bfdeca4b7913b7d9fbc9a681460a91ace807e1d0 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Sun, 9 Jun 2019 10:58:52 -0700 Subject: [PATCH] start building out the muxed client Domain --- src/server/domain.rs | 46 ++++++++++++++++++++++++++++++++++++++++++++ src/server/mod.rs | 1 + 2 files changed, 47 insertions(+) create mode 100644 src/server/domain.rs diff --git a/src/server/domain.rs b/src/server/domain.rs new file mode 100644 index 000000000..abd8f9d66 --- /dev/null +++ b/src/server/domain.rs @@ -0,0 +1,46 @@ +use crate::mux::domain::{alloc_domain_id, Domain, DomainId}; +use crate::mux::tab::Tab; +use crate::server::client::Client; +use crate::server::codec::Spawn; +use failure::{bail, Fallible}; +use portable_pty::{CommandBuilder, PtySize}; +use std::rc::Rc; +use std::sync::{Arc, Mutex}; + +pub struct ClientDomain { + client: Arc>, + local_domain_id: DomainId, + remote_domain_id: DomainId, +} + +impl ClientDomain { + pub fn new(client: &Arc>) -> Self { + let local_domain_id = alloc_domain_id(); + // Assumption: that the domain id on the other end is + // always the first created default domain. In the future + // we'll add a way to discover/enumerate domains to populate + // this a bit rigorously. + let remote_domain_id = 0; + Self { + client: Arc::clone(client), + local_domain_id, + remote_domain_id, + } + } +} + +impl Domain for ClientDomain { + fn domain_id(&self) -> DomainId { + self.local_domain_id + } + + fn spawn(&self, size: PtySize, command: Option) -> Fallible> { + let mut client = self.client.lock().unwrap(); + let remote_tab_id = client.spawn(Spawn { + domain_id: self.remote_domain_id, + size, + command, + }); + bail!("need to wrap in a tab proxy"); + } +} diff --git a/src/server/mod.rs b/src/server/mod.rs index 07553bf05..8a5c73aa3 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -5,4 +5,5 @@ use uds_windows::{UnixListener, UnixStream}; pub mod client; pub mod codec; +pub mod domain; pub mod listener;