handleCommand method
Handle the /remote-control command.
If already connected (not outbound-only), shows the disconnect dialog. Otherwise, checks prerequisites and initiates connection.
Implementation
Future<String?> handleCommand({String? name}) async {
final cfg = config.value;
// If already connected in full mode, show disconnect dialog.
if ((cfg.connected || cfg.enabled) && !cfg.outboundOnly) {
showDisconnectDialog.value = true;
return null; // Dialog will handle the response.
}
// Check prerequisites.
isConnecting.value = true;
try {
final result = await checkBridgePrerequisites();
if (!result.canConnect) {
errorMessage.value = result.errorMessage;
return result.errorMessage;
}
// Enable bridge connection.
config.value.enable(name: name);
config.refresh();
return 'Remote Control connecting...';
} finally {
isConnecting.value = false;
}
}