send method
Implementation
@override
Future<void> send(Object? message) {
if (_closedCompleter.isCompleted || _closeFuture != null) {
return Future<void>.error(const AcpTransportClosedException());
}
return _outbound.add(() async {
try {
final encoded = jsonEncode(message);
if (encoded.contains('\n') || encoded.contains('\r')) {
throw const FormatException(
'Encoded ACP messages must occupy exactly one line.',
);
}
_process.stdin.writeln(encoded);
await _process.stdin.flush();
} catch (error) {
if (error is AcpTransportException) rethrow;
throw AcpTransportException(
'Failed to encode or write an ACP message.',
cause: error,
);
}
});
}