subscribe method

  1. @override
Future<String> subscribe(
  1. String topic, {
  2. RelayerSubscribeOptions? opts,
})
override

Implementation

@override
Future<String> subscribe(
  String topic, {
  RelayerSubscribeOptions? opts,
}) async {
  _isInitialized();
  logger.d('Subscribing Topic');
  logger.v({
    'type': "method",
    'method': "subscribe",
    'params': {
      'topic': topic,
      'opts': opts?.toJson(),
    },
  });
  try {
    final relay = getRelayProtocolName(opts);
    final params = SubscriberParams(relay: relay, topic: topic);
    pending[topic] = params;
    final id = await _rpcSubscribe(topic, relay);
    _onSubscribe(id, params);
    logger.d('Successfully Subscribed Topic');
    logger.v({
      'type': "method",
      'method': "subscribe",
      'params': {
        'topic': topic,
        'opts': opts?.toJson(),
      },
    });
    return id;
  } catch (e) {
    logger.d('Failed to Subscribe Topic');
    logger.e(e.toString());
    rethrow;
  }
}