unsubscribe method
Future<void>
unsubscribe(
{ - required String topic,
})
override
Implementation
@override
Future<void> unsubscribe({required String topic}) async {
_checkInitialized();
core.logger.i('[$runtimeType] unsubscribe, $topic');
String id = topicMap.get(topic) ?? '';
try {
await _sendJsonRpcRequest(
_buildMethod(JSON_RPC_UNSUBSCRIBE),
{
'topic': topic,
'id': id,
},
JsonRpcUtils.payloadId(entropy: 6),
);
} catch (e, s) {
core.logger.e('[$runtimeType], unsubscribe: $e', stackTrace: s);
onRelayClientError.broadcast(ErrorEvent(e));
}
// Remove the subscription
pendingSubscriptions.remove(topic);
await topicMap.delete(topic);
// Delete all the messages
await messageTracker.delete(topic);
}