From aba90f2e9047451a3b0807ee9f2f1568c43ff118 Mon Sep 17 00:00:00 2001 From: "Alexander \"PapaTutuWawa" Date: Wed, 27 Sep 2023 18:58:17 +0200 Subject: [PATCH] feat(example): Print the number of users in the MUC --- examples_dart/bin/muc_client.dart | 15 ++++++++++----- packages/moxxmpp/lib/src/xeps/xep_0045/types.dart | 1 + 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/examples_dart/bin/muc_client.dart b/examples_dart/bin/muc_client.dart index 4e88c84..1eeb11e 100644 --- a/examples_dart/bin/muc_client.dart +++ b/examples_dart/bin/muc_client.dart @@ -75,11 +75,16 @@ void main(List args) async { }); // Join room - await connection.getManagerById(mucManager)!.joinRoom( - muc, - nick, - maxHistoryStanzas: 0, - ); + final mm = connection.getManagerById(mucManager)!; + await mm.joinRoom( + muc, + nick, + maxHistoryStanzas: 0, + ); + final state = (await mm.getRoomState(muc))!; + + print('=====> ${state.members.length} users in room'); + print('=====> ${state.members.values.map((m) => m.nick).join(", ")}'); final repl = Repl(prompt: '> '); await for (final line in repl.runAsync()) { diff --git a/packages/moxxmpp/lib/src/xeps/xep_0045/types.dart b/packages/moxxmpp/lib/src/xeps/xep_0045/types.dart index a58866c..06bb806 100644 --- a/packages/moxxmpp/lib/src/xeps/xep_0045/types.dart +++ b/packages/moxxmpp/lib/src/xeps/xep_0045/types.dart @@ -5,6 +5,7 @@ import 'package:moxxmpp/src/xeps/xep_0004.dart'; import 'package:moxxmpp/src/xeps/xep_0030/types.dart'; class InvalidAffiliationException implements Exception {} + class InvalidRoleException implements Exception {} enum Affiliation {