copyPayloadTo method

void copyPayloadTo(
  1. AbstractMessageWithPayload message
)

Transfers the message payload to another message

Implementation

void copyPayloadTo(AbstractMessageWithPayload message) {
  final copier = _OwnedPayloadCopier();
  message.attachE2eeProvider(e2eeProvider);
  message.attachE2eeRuntimeContext(e2eeRuntimeContext);
  message.transparentBinaryPayload =
      copier.copy(transparentBinaryPayload) as Uint8List?;

  if ((_encodedArguments != null && _argumentsDecoder != null) ||
      (_encodedArgumentsKeywords != null &&
          _argumentsKeywordsDecoder != null)) {
    message.setLazyPayload(
      argumentsBytes: copier.copy(_encodedArguments) as Uint8List?,
      argumentsDecoder: _argumentsDecoder,
      argumentsKeywordsBytes:
          copier.copy(_encodedArgumentsKeywords) as Uint8List?,
      argumentsKeywordsDecoder: _argumentsKeywordsDecoder,
      encoding: _lazyPayloadEncoding,
    );
    if (_encodedArguments == null) {
      message.arguments = copier.copy(_arguments) as List<dynamic>?;
    }
    if (_encodedArgumentsKeywords == null) {
      message.argumentsKeywords =
          copier.copy(_argumentsKeywords) as Map<String, dynamic>?;
    }
    message._pptPayloadDecoded = _pptPayloadDecoded;
  } else {
    message._lazyPayloadEncoding = _lazyPayloadEncoding;
    message.arguments = copier.copy(_arguments) as List<dynamic>?;
    message.argumentsKeywords =
        copier.copy(_argumentsKeywords) as Map<String, dynamic>?;
    message._pptPayloadDecoded = _pptPayloadDecoded;
  }
  final retainedLazyPayload = _retainedLazyPayload;
  if (retainedLazyPayload != null) {
    message.retainLazyPayload(retainedLazyPayload._toOwned(copier));
  }
}