diff --git a/example_flutter/lib/main.dart b/example_flutter/lib/main.dart index b85a122..c30ba5c 100644 --- a/example_flutter/lib/main.dart +++ b/example_flutter/lib/main.dart @@ -83,8 +83,6 @@ class _MyHomePageState extends State { ), MessageManager(), PresenceManager(), - OccupantIdManager(), - MUCManager() ]) ..registerFeatureNegotiators([ ResourceBindingNegotiator(), @@ -160,47 +158,6 @@ class _MyHomePageState extends State { ), obscureText: true, ), - TextButton( - onPressed: () async { - // final muc = connection.getManagerById(mucManager); - // final roomInformationResult = await muc!.queryRoomInformation( - // JID.fromString('moxxmpp-muc-test@muc.moxxy.org')); - // if (roomInformationResult.isType()) { - // print('Room information received'); - // print(roomInformationResult.get().jid); - // print(roomInformationResult.get().name); - // print(roomInformationResult.get().features); - // } - - // final muc = connection.getManagerById(mucManager); - // print('joining room'); - // final roomInformationResult = await muc!.joinRoom( - // JID.fromString('moxxmpp-muc-test@muc.moxxy.org/test_1')); - // if (roomInformationResult.isType()) { - // print(roomInformationResult.get()); - // } else { - // print(roomInformationResult.get()); - // } - - print('HERE IS YOUR JID'); - print(connection.resource); - final sid = connection.generateId(); - final originId = connection.generateId(); - final message = - connection.getManagerById(messageManager); - message!.sendMessage( - JID.fromString('moxxmpp-muc-test@muc.moxxy.org/ISD'), - TypedMap.fromList([ - const MessageBodyData('Testing'), - const MarkableData(true), - MessageIdData(sid), - StableIdData(originId, null), - ConversationTypeData(ConversationType.groupchatprivate) - ]), - ); - }, - child: const Text('Test'), - ), ], ), ), diff --git a/packages/moxxmpp/lib/src/xeps/xep_0045/types.dart b/packages/moxxmpp/lib/src/xeps/xep_0045/types.dart index 8dcceed..31e2c80 100644 --- a/packages/moxxmpp/lib/src/xeps/xep_0045/types.dart +++ b/packages/moxxmpp/lib/src/xeps/xep_0045/types.dart @@ -23,7 +23,7 @@ class RoomInformation { .name!, ); - /// The JID (Jabber ID) of the Multi-User Chat (MUC) room. + /// The JID of the Multi-User Chat (MUC) room. final JID jid; /// A list of features supported by the Multi-User Chat (MUC) room. @@ -36,10 +36,8 @@ class RoomInformation { class RoomState { RoomState({ required this.roomJid, - required this.roomInformation, this.nick, }); final JID roomJid; - final RoomInformation roomInformation; String? nick; } diff --git a/packages/moxxmpp/lib/src/xeps/xep_0045/xep_0045.dart b/packages/moxxmpp/lib/src/xeps/xep_0045/xep_0045.dart index 39a3e4d..1a32c79 100644 --- a/packages/moxxmpp/lib/src/xeps/xep_0045/xep_0045.dart +++ b/packages/moxxmpp/lib/src/xeps/xep_0045/xep_0045.dart @@ -13,13 +13,6 @@ import 'package:moxxmpp/src/xeps/xep_0045/errors.dart'; import 'package:moxxmpp/src/xeps/xep_0045/types.dart'; import 'package:synchronized/synchronized.dart'; -enum ConversationType { chat, groupchat, groupchatprivate } - -class ConversationTypeData extends StanzaHandlerExtension { - ConversationTypeData(this.conversationType); - final ConversationType conversationType; -} - class MUCManager extends XmppManagerBase { MUCManager() : super(mucManager); @@ -45,14 +38,6 @@ class MUCManager extends XmppManagerBase { final roomInformation = RoomInformation.fromDiscoInfo( discoInfo: result.get(), ); - await _cacheLock.synchronized( - () async { - _mucRoomCache[roomJID] = RoomState( - roomJid: roomJID, - roomInformation: roomInformation, - ); - }, - ); return Result(roomInformation); } catch (e) { return Result(InvalidDiscoInfoResponse); @@ -80,7 +65,7 @@ class MUCManager extends XmppManagerBase { ), ); await _cacheLock.synchronized( - () async { + () { _mucRoomCache[roomJID]!.nick = nick; }, ); @@ -90,15 +75,8 @@ class MUCManager extends XmppManagerBase { Future> leaveRoom( JID roomJID, ) async { - String? nick; - await _cacheLock.synchronized( - () async { - nick = _mucRoomCache[roomJID]!.nick; - }, - ); - if (nick!.isEmpty) { - return Result(NoNicknameSpecified()); - } + final nick = + await _cacheLock.synchronized(() => _mucRoomCache[roomJID]!.nick); await getAttributes().sendStanza( StanzaDetails( Stanza.presence( @@ -108,7 +86,7 @@ class MUCManager extends XmppManagerBase { ), ); await _cacheLock.synchronized( - () async { + () { _mucRoomCache.remove(roomJID); }, );