feat(example): Print the number of users in the MUC

This commit is contained in:
PapaTutuWawa 2023-09-27 18:58:17 +02:00
parent 9211963390
commit aba90f2e90
2 changed files with 11 additions and 5 deletions

View File

@ -75,11 +75,16 @@ void main(List<String> args) async {
}); });
// Join room // Join room
await connection.getManagerById<MUCManager>(mucManager)!.joinRoom( final mm = connection.getManagerById<MUCManager>(mucManager)!;
await mm.joinRoom(
muc, muc,
nick, nick,
maxHistoryStanzas: 0, 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: '> '); final repl = Repl(prompt: '> ');
await for (final line in repl.runAsync()) { await for (final line in repl.runAsync()) {

View File

@ -5,6 +5,7 @@ import 'package:moxxmpp/src/xeps/xep_0004.dart';
import 'package:moxxmpp/src/xeps/xep_0030/types.dart'; import 'package:moxxmpp/src/xeps/xep_0030/types.dart';
class InvalidAffiliationException implements Exception {} class InvalidAffiliationException implements Exception {}
class InvalidRoleException implements Exception {} class InvalidRoleException implements Exception {}
enum Affiliation { enum Affiliation {