publish method
Future<void>
publish({
- required String topic,
- required String message,
- RelayerPublishOptions? opts,
override
Implementation
@override
Future<void> publish({
required String topic,
required String message,
RelayerPublishOptions? opts,
}) async {
logger.d('Publishing Payload');
logger.v({
'type': "method",
'method': "publish",
'params': {
'topic': topic,
'message': message,
'opts': opts?.toJson(),
},
});
try {
final ttl = opts?.ttl ?? PUBLISHER_DEFAULT_TTL;
final relay = getRelayProtocolName(opts);
final prompt = opts?.prompt ?? false;
final tag = opts?.tag ?? 0;
final params = PublisherParams(
topic: topic,
message: message,
opts: RelayerPublishOptions(
ttl: ttl,
relay: relay,
prompt: prompt,
tag: tag,
),
);
final hash = await hashMessage(message);
_queue[hash] = params;
await _rpcPublish(topic, message, ttl, relay, prompt, tag);
_onPublish(hash);
logger.d('Successfully Published Payload');
logger.v({
'type': "method",
'method': "publish",
'params': {
'topic': topic,
'message': message,
'opts': opts?.toJson(),
},
});
} catch (e) {
logger.d('Failed to Publish Payload');
logger.e(e.toString());
rethrow;
}
}