sendRequest method

Future<Map<String, dynamic>?> sendRequest(
  1. String filePath,
  2. String method,
  3. Map<String, dynamic> params
)

Send a request to the server handling a file.

Implementation

Future<Map<String, dynamic>?> sendRequest(
  String filePath,
  String method,
  Map<String, dynamic> params,
) async {
  final server = await ensureServerForFile(filePath);
  if (server == null) return null;

  try {
    return await server.sendRequest(method, params);
  } catch (e) {
    // Transient error retry for "content modified"
    if (e.toString().contains('-32801')) {
      await Future.delayed(const Duration(milliseconds: 100));
      return server.sendRequest(method, params);
    }
    rethrow;
  }
}