MqttArchiveHandler constructor
MqttArchiveHandler({
- required ClientHandler clientHandler,
Implementation
MqttArchiveHandler({
required this.clientHandler,
}) {
clientHandler.allMessagesStream().listen((payloadEvent) {
String topic = payloadEvent.topic;
String payload = payloadEvent.payload;
if (topic.isMembershipArchivesTopic) {
try {
Iterable l = jsonDecode(payload);
List<RoomMembershipMessage> contacts =
List<RoomMembershipMessage>.from(
l.map((model) => RoomMembershipMessage.fromJson(model)));
for (var contact in contacts) {
//======================================//
clientHandler.joinRoom(contact.roomId);
clientHandler.joinContactEvents(contact.id);
//======================================//
}
_contactsController.add(contacts);
} catch (e) {
debugPrint(e.toString());
}
} else if (topic.isMyProfileArchiveTopic) {
User user = User.fromString(payload);
clientHandler.joinMyEvents(user.id);
_userController.add(user);
}
});
}