On this page
Server.connected(attachingTo:_:)
- Declared in
- Server
- Package
- libtmux-swift
- Source
- Sources/LibTmux/ControlMode.swift
- connected(attachingTo:_:) ( attachingTo : String , body : @escaping (Server, ControlSession) async throws -> Result ) Result
-
Runs
bodywith every command carried by one live connection instead of a new tmux process each time.The server handed to
bodyis this server: the same calls, the same return types, the same errors. Only how the work reaches tmux changes.A connection is a client, and tmux has no client that is attached to nothing — a control client with no target runs tmux's default command and creates a session. So the connection attaches to
session, and that is visible in what the server reports about itself: that session reads as attached, andServer/clients()includes the connection. Nothing else differs.The connection is handed over too, because it can do one thing a process cannot: report what changed without being asked. That capability exists only here, and so does the value carrying it — there is no way to write a
%outputreader against a server that has no connection.The handed-out values do not keep the connection alive. Do not return or store them; calls made after
bodyends fail because the process has already been reaped.- Parameters:
- session: the session to attach to, which must already exist.
- body: the work to run, given this server and the connection carrying it.
- Throws:
TmuxError/connectionClosedif the connection ends beforebody, including whenbodydetaches its own client.
- Raises
- Parameters:
0 declared, 0 inherited