mirror of
https://github.com/wez/wezterm.git
synced 2024-11-27 12:23:46 +03:00
prep for dealing with unilaterally sent pdus
This commit is contained in:
parent
764597851c
commit
1d2b4291d3
@ -146,10 +146,10 @@ fn run_terminal_gui(config: Arc<config::Config>, opts: &StartCommand) -> Result<
|
|||||||
};
|
};
|
||||||
|
|
||||||
let domain: Arc<dyn Domain> = if opts.mux_client_as_default_domain {
|
let domain: Arc<dyn Domain> = if opts.mux_client_as_default_domain {
|
||||||
let client = Client::new_unix_domain(&config)?;
|
let client = Client::new_unix_domain(&config, None)?;
|
||||||
Arc::new(ClientDomain::new(client))
|
Arc::new(ClientDomain::new(client))
|
||||||
} else if opts.mux_tls_client_as_default_domain {
|
} else if opts.mux_tls_client_as_default_domain {
|
||||||
let client = Client::new_tls(&config)?;
|
let client = Client::new_tls(&config, None)?;
|
||||||
Arc::new(ClientDomain::new(client))
|
Arc::new(ClientDomain::new(client))
|
||||||
} else {
|
} else {
|
||||||
Arc::new(LocalDomain::new(&config)?)
|
Arc::new(LocalDomain::new(&config)?)
|
||||||
@ -210,7 +210,7 @@ fn main() -> Result<(), Error> {
|
|||||||
run_terminal_gui(config, &start)
|
run_terminal_gui(config, &start)
|
||||||
}
|
}
|
||||||
SubCommand::Cli(cli) => {
|
SubCommand::Cli(cli) => {
|
||||||
let client = Client::new_unix_domain(&config)?;
|
let client = Client::new_unix_domain(&config, None)?;
|
||||||
match cli.sub {
|
match cli.sub {
|
||||||
CliSubCommand::List => {
|
CliSubCommand::List => {
|
||||||
let cols = vec![
|
let cols = vec![
|
||||||
|
@ -57,8 +57,12 @@ macro_rules! rpc {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn client_thread(mut stream: Box<dyn ReadAndWrite>, rx: Receiver<ReaderMessage>) -> Fallible<()> {
|
fn client_thread(
|
||||||
let mut next_serial = 0u64;
|
mut stream: Box<dyn ReadAndWrite>,
|
||||||
|
rx: Receiver<ReaderMessage>,
|
||||||
|
_unilaterals: Option<Sender<Pdu>>,
|
||||||
|
) -> Fallible<()> {
|
||||||
|
let mut next_serial = 1u64;
|
||||||
let mut promises = HashMap::new();
|
let mut promises = HashMap::new();
|
||||||
loop {
|
loop {
|
||||||
let msg = if promises.is_empty() {
|
let msg = if promises.is_empty() {
|
||||||
@ -104,11 +108,11 @@ fn client_thread(mut stream: Box<dyn ReadAndWrite>, rx: Receiver<ReaderMessage>)
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Client {
|
impl Client {
|
||||||
pub fn new(stream: Box<dyn ReadAndWrite>) -> Self {
|
pub fn new(stream: Box<dyn ReadAndWrite>, unilaterals: Option<Sender<Pdu>>) -> Self {
|
||||||
let (sender, receiver) = channel();
|
let (sender, receiver) = channel();
|
||||||
|
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
if let Err(e) = client_thread(stream, receiver) {
|
if let Err(e) = client_thread(stream, receiver, unilaterals) {
|
||||||
log::error!("client thread ended: {}", e);
|
log::error!("client thread ended: {}", e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -116,7 +120,10 @@ impl Client {
|
|||||||
Self { sender }
|
Self { sender }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_unix_domain(config: &Arc<Config>) -> Fallible<Self> {
|
pub fn new_unix_domain(
|
||||||
|
config: &Arc<Config>,
|
||||||
|
unilaterals: Option<Sender<Pdu>>,
|
||||||
|
) -> Fallible<Self> {
|
||||||
let sock_path = Path::new(
|
let sock_path = Path::new(
|
||||||
config
|
config
|
||||||
.mux_server_unix_domain_socket_path
|
.mux_server_unix_domain_socket_path
|
||||||
@ -125,10 +132,10 @@ impl Client {
|
|||||||
);
|
);
|
||||||
info!("connect to {}", sock_path.display());
|
info!("connect to {}", sock_path.display());
|
||||||
let stream = Box::new(UnixStream::connect(sock_path)?);
|
let stream = Box::new(UnixStream::connect(sock_path)?);
|
||||||
Ok(Self::new(stream))
|
Ok(Self::new(stream, unilaterals))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_tls(config: &Arc<Config>) -> Fallible<Self> {
|
pub fn new_tls(config: &Arc<Config>, unilaterals: Option<Sender<Pdu>>) -> Fallible<Self> {
|
||||||
let remote_address = config
|
let remote_address = config
|
||||||
.mux_server_remote_address
|
.mux_server_remote_address
|
||||||
.as_ref()
|
.as_ref()
|
||||||
@ -171,7 +178,7 @@ impl Client {
|
|||||||
e
|
e
|
||||||
)
|
)
|
||||||
})?);
|
})?);
|
||||||
Ok(Self::new(stream))
|
Ok(Self::new(stream, unilaterals))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn send_pdu(&self, pdu: Pdu) -> Future<Pdu> {
|
pub fn send_pdu(&self, pdu: Pdu) -> Future<Pdu> {
|
||||||
|
Loading…
Reference in New Issue
Block a user