RpcClient constructor

RpcClient(
  1. RpcService service, {
  2. RpcSubscribeCallback? subscribeCallback,
})

Implementation

RpcClient(this.service, {RpcSubscribeCallback? subscribeCallback}) {
  api = RpcApi(
    service,
    typeFactory: convertJson,
    subscribeCallback: (data) {
      final response = convertJson<RpcFilterResponse>(data);

      final mapping = subscriptionCallbackMapping[response.subscription];
      if (mapping != null) {
        mapping(response);
        return;
      }

      if (subscribeCallback != null) {
        subscribeCallback(response);
      }
    },
  );
  typeMapping = {}
    ..addAll(RpcContract.factories)
    ..addAll(RpcLedger.factories)
    ..addAll(RpcNet.factories)
    ..addAll(RpcSubscribe.factories)
    ..addAll(RpcWallet.factories);
}