ChatManager constructor

ChatManager(
  1. Connection _connection
)

Implementation

ChatManager(this._connection) {
  _connection.inStanzasStream
      .where((abstractStanza) => abstractStanza is MessageStanza)
      .map((stanza) => stanza as MessageStanza?)
      .listen((stanza) {
    var message = Message.fromStanza(stanza!);
    // find jid different from mine
    var buddyJid =
        _connection.fullJid.userAtDomain == message.to!.userAtDomain
            ? message.from!
            : message.to!;
    var chat = _getChat(buddyJid);
    chat.parseMessage(message);
  });
}