routeData method

void routeData(
  1. DataMessage data
)

Process data message

Implementation

void routeData(DataMessage data) {
  if (data.content != null) {
    if (touched?.isBefore(data.ts!) == true) {
      touched = data.ts;
    }
  }

  if (data.seq! > _maxSeq) {
    _maxSeq = data.seq!;
  }

  if (data.seq! < _minSeq || _minSeq == 0) {
    _minSeq = data.seq!;
  }

  if (!data.noForwarding!) {
    _messages.put([data]);
    _updateDeletedRanges();
  }

  onData.add(data);

  // Update locally cached contact with the new message count.
  var me = _tinodeService.getTopic(topic_names.TOPIC_ME) as TopicMe;
  me.setMsgReadRecv(
      name ?? '',
      (data.from == null || _tinodeService.isMe(data.from!)) ? 'read' : 'msg',
      data.seq!,
      data.ts);
}