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) ?? '';
  // print('Unsub from id: $id');

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

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

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