On this page
server.Server.sessions
- Module
- server
- Declared in
- Server
- Package
- @libtmux/libtmux
- Source
- packages/libtmux/src/server.ts
- Other languages
- PythonRustGoJava.NETC++Swift
-
Every session on the server, read now.
This and its three siblings each take a snapshot of their own — one daemon identity read and four listings per call — so calling several in a row describes several different instants and pays for each. Inside a loop that is an N+1: prefer one
snapshotand readsessions,windows,panes, andclientsoff it, which is both cheaper and consistent.Examples
// One invocation, and every collection agrees with the others. const now = await server.snapshot(); for (const session of now.sessions) console.log(session.name, session.windows.length);const sessions = await server.sessions(); sessions.where({ name: "work" }).count();Discussed in Traversal
In other languages List the server’s sessions
Examples
// One invocation, and every collection agrees with the others.
const now = await server.snapshot();
for (const session of now.sessions) console.log(session.name, session.windows.length); const sessions = await server.sessions();
sessions.where({ name: "work" }).count(); let guard = libtmux::test::TestServer::new().await?;
guard.session("work").await?;
let sessions = guard.server().sessions().await?;
assert_eq!(sessions.len(), 1);
assert!(sessions[0].id().to_string().starts_with('$'));
guard.shutdown().await?; 0 declared, 0 inherited