publish method

  1. @override
Future<void> publish({
  1. required String topic,
  2. required String message,
  3. required int ttl,
  4. required int tag,
})
override

Implementation

@override
Future<void> publish({
  required String topic,
  required String message,
  required int ttl,
  required int tag,
}) async {
  _checkInitialized();

  core.logger.i('[$runtimeType] publish, $topic, $message');

  Map<String, dynamic> data = {
    'message': message,
    'ttl': ttl,
    'topic': topic,
    'tag': tag,
  };

  try {
    await messageTracker.recordMessageEvent(topic, message);
    var _ = await _sendJsonRpcRequest(
      _buildMethod(JSON_RPC_PUBLISH),
      data,
      JsonRpcUtils.payloadId(entropy: 6),
    );
  } catch (e, s) {
    core.logger.e('[$runtimeType], publish: $e', stackTrace: s);
    onRelayClientError.broadcast(ErrorEvent(e));
  }
}