Many fixes for the clipboard and others

- Reverse connections must be maintained to ensure messages are
  processed in order. (Whoops!)
- The clipboard context must remain live in order for the data to
  remain available for applications, at least on X11. (And it couldn't
  hurt elsewhere, either, I guess.)
- Print out the server version at startup time, so we can be sure what
  we're talking to.
- Print out the full details of the error when something goes wrong
  with `browse` or `clip`.
This commit is contained in:
John Doty 2024-08-08 10:03:47 -07:00
parent a3fa032500
commit 2a582e25a8
7 changed files with 110 additions and 57 deletions

View file

@ -26,12 +26,26 @@ async fn server_loop<Reader: AsyncRead + Unpin>(
) -> Result<()> {
// The first message we send must be an announcement.
writer.send(Message::Hello(0, 2, vec![])).await?;
let mut version_reported = false;
loop {
use Message::*;
match reader.read().await? {
Ping => (),
Refresh => {
// Just log the version, if we haven't yet. We do this extra
// work to avoid spamming the log, but we wait until we
// receive the first message to be sure that the client is in
// a place to display our logging properly.
if !version_reported {
eprintln!(
"fwd server {} (rev {}{})",
crate::VERSION,
crate::REV,
crate::DIRTY
);
version_reported = true;
}
let ports = match refresh::get_entries().await {
Ok(ports) => ports,
Err(e) => {