openSession method
Opens a session on nodeId.
Completes once the node confirms the session, or throws SessionRejectedException if it is refused.
Implementation
Future<RemoteSession> openSession({
required String nodeId,
SessionMode mode = SessionMode.exec,
String? command,
List<String> args = const [],
Map<String, String> env = const {},
String? cwd,
PtySpec? pty,
String? resumeSessionId,
}) async {
_ensureConnected();
final Channel channel = _mux!.open();
final session = RemoteSession(channel, mode);
_connection!.send(
ControlFrame(
SessionOpen(
channel: channel.id,
nodeId: nodeId,
mode: mode,
command: command,
args: args,
env: env,
cwd: cwd,
pty: pty,
resumeSessionId: resumeSessionId,
),
),
);
try {
await session.opened;
} on Object {
await _mux!.closeChannel(channel.id);
rethrow;
}
return session;
}