processMetaDesc method

  1. @override
void processMetaDesc(
  1. TopicDescription desc
)
override

Override the original Topic.processMetaDesc.

Implementation

@override
void processMetaDesc(TopicDescription desc) {
  // Check if online contacts need to be turned off because P permission was removed.
  var turnOff = (desc.acs != null && !desc.acs!.isPresencer(null)) &&
      acs.isPresencer(null);

  // Copy parameters from desc object to this topic
  acs = desc.acs ?? acs;
  clear = desc.clear ?? clear;
  created = desc.created ?? created;
  defacs = desc.defacs ?? defacs;
  private = desc.private ?? private;
  public = desc.public ?? public;
  read = desc.read ?? read;
  recv = desc.recv ?? recv;
  seq = desc.seq ?? seq;
  status = desc.status ?? status;
  updated = desc.updated ?? updated;
  touched = desc.touched ?? touched;

  if (turnOff) {
    _contacts.forEach((key, cont) {
      if (cont.online == true) {
        cont.online = false;
        if (cont.seen != null) {
          cont.seen!.when = DateTime.now();
        } else {
          cont.seen = Seen(when: DateTime.now());
        }
        onContactUpdate.add(ContactUpdateEvent('off', cont));
      }
    });
  }

  onMetaDesc.add(this);
}