unsubscribe method

  1. @override
Future<void> unsubscribe(
  1. String topic
)
override

Implementation

@override
Future<void> unsubscribe(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,
      },
    );
  } catch (e) {
    onRelayClientError.broadcast(ErrorEvent(e));
  }

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

  // Delete all the messages
  messageTracker!.deleteSubscriptionMessages(topic);
}