tinode / dart-sdk

Dart SKD for using Tinode messenger in dart and flutter applications.
https://pub.dev/packages/tinode
Apache License 2.0
41 stars 21 forks source link

onPres can not will be triggered when a `pres` message is received #19

Open c1s1x1 opened 3 years ago

c1s1x1 commented 3 years ago

lib/src/models/server-messages.dart

static PresMessage fromMessage(Map<String, dynamic> msg) {
    return PresMessage(
      topic: msg['msg'],
      src: msg['src'],
      what: msg['what'],
      seq: msg['seq'],
      clear: msg['clear'],
      delseq:
          msg['delseq'] != null && msg['delseq'].length != null ? msg['delseq'].map((seq) => DeleteTransactionRange.fromMessage(seq)).toList() : [],
      ua: msg['ua'],
      act: msg['act'],
      tgt: msg['tgt'],
      acs: msg['acs'] != null ? AccessMode(msg['acs']) : null,
      dacs: msg['dacs'] != null ? AccessMode(msg['dacs']) : null,
    );
  }
}

需要改为

static PresMessage fromMessage(Map<String, dynamic> msg) {
    return PresMessage(
      topic: msg['topic'],
      src: msg['src'],
      what: msg['what'],
      seq: msg['seq'],
      clear: msg['clear'],
      delseq:
          msg['delseq'] != null && msg['delseq'].length != null ? msg['delseq'].map((seq) => DeleteTransactionRange.fromMessage(seq)).toList() : [],
      ua: msg['ua'],
      act: msg['act'],
      tgt: msg['tgt'],
      acs: msg['acs'] != null ? AccessMode(msg['acs']) : null,
      dacs: msg['dacs'] != null ? AccessMode(msg['dacs']) : null,
    );
  }
}

否则

grp!.onPres.listen

无法获取到最新的数据