1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-24 07:46:59 +03:00

start building out the muxed client Domain

This commit is contained in:
Wez Furlong 2019-06-09 10:58:52 -07:00
parent e98d8acb96
commit bfdeca4b79
2 changed files with 47 additions and 0 deletions

46
src/server/domain.rs Normal file
View File

@ -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<Mutex<Client>>,
local_domain_id: DomainId,
remote_domain_id: DomainId,
}
impl ClientDomain {
pub fn new(client: &Arc<Mutex<Client>>) -> 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<CommandBuilder>) -> Fallible<Rc<dyn Tab>> {
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");
}
}

View File

@ -5,4 +5,5 @@ use uds_windows::{UnixListener, UnixStream};
pub mod client;
pub mod codec;
pub mod domain;
pub mod listener;