isConnected method

Future<bool> isConnected()

Checks if the SSH client is connected.

Returns true if connected, false otherwise.

Implementation

Future<bool> isConnected() async {
  if (client == null || client!.isClosed) return false;
  try {
    // Attempt to execute a simple command to check the connection status
    final result = await sendCommand('echo "check connection"');
    return result != null;
  } catch (e) {
    // If an exception occurs, the connection is not active
    return false;
  }
}