unsubscribe method

  1. @override
Future<void> unsubscribe({
  1. required String topic,
})
override

Implementation

@override
Future<void> unsubscribe({required String topic}) async {
  _checkInitialized();

  String id = topicMap.get(topic) ?? '';

  try {
    await _sendJsonRpcRequest(
      _buildMethod(JSON_RPC_UNSUBSCRIBE),
      {
        'topic': topic,
        'id': id,
      },
      JsonRpcUtils.payloadId(entropy: 6),
    );
  } catch (e) {
    onRelayClientError.broadcast(ErrorEvent(e));
  }

  // Remove the subscription
  pendingSubscriptions.remove(topic);
  await topicMap.delete(topic);

  // Delete all the messages
  await messageTracker.delete(topic);
}