# server.Server.over_control_mode

- **Module:** server.Server
- **Package:** libtmux
- **Language:** Rust
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-rs/blob/f0e37052c232636b61d095817046e6bfc8f2ca40/crates/libtmux/src/server.rs#L1739
- **Page:** https://libtmux.org/en/rs/latest/reference/server-server-over_control_mode/

```
server.Server.over_control_mode(self, sender: &crate::control::ControlSender) -> Result<Self, Error>
```

Return a handle whose commands run over an open control connection.

Every typed call on the returned server -- `sessions`, `send_keys`,
`capture`, the option and hook accessors -- is written to `sender` as
one control-mode line and answered from its `%begin`/`%end` block,
rather than spawning `tmux`. Handles reached through it inherit the
route, because they carry the same connection.

The original server is unchanged and still dispatches processes. Use it
for the two things a connection is wrong for: a command that answers at
once and then parks the client's queue, such as `wait-for` or a
foreground `run-shell`, and a command whose arguments are not valid
UTF-8, which a text protocol cannot carry.

Commands wait for the sender's own [`reply_timeout`], not this server's
[`default_timeout`]. They are not the same budget: one bounds a round
trip on an open connection, the other bounds forking tmux.

# Draining events

The connection stops reading tmux once a caller is far enough behind on
[`ControlEvents`], and refuses commands past that. Either keep reading
events, drop the watching half, or narrow what tmux reports with
[`ControlSender::watch_only`].

# Errors

Returns an error when the sender reaches a different server, or when
the tmux version cannot be detected. Detection runs here, once, through
this server's process transport, because `tmux -V` is a client flag and
has no control-mode spelling; the returned handle never probes.

## Example

```rust
use libtmux::control::ControlMode;
use libtmux::test::TestServer;

let guard = TestServer::new().await?;
let session = guard.server().new_session("routed").await?;

let (sender, events) = ControlMode::attach(guard.server(), session.id())
    .await?
    .split();
let routed = guard.server().over_control_mode(&sender).await?;

// One line on the connection, not a process.
assert_eq!(routed.sessions().await?.len(), 1);

// And a handle it found keeps the route.
let pane = routed.panes().await?.remove(0);
pane.send_line("true").await?;

events.shutdown().await?;
guard.shutdown().await?;
```
