send method

  1. @override
Future<RpcResponse> send(
  1. String method,
  2. List params
)
override

Send arbitrary message to RPC node

Implementation

@override
Future<RpcResponse> send(String method, List<dynamic> params) async {
  if (channel == null) {
    throw Exception('WebsocketChannel is closed');
  }
  await channel!.ready;

  final id = _sequence++;
  final completer = Completer<RpcResponse>();
  queries[id] = completer;

  channel!.sink.add(jsonEncode({
    'id': id,
    'jsonrpc': '2.0',
    'method': method,
    'params': params,
  }));

  return completer.future;
}