githubw2015 / asmack

一个小的例子
https://github.com/githubw2015/asmack
Other
0 stars 0 forks source link

InvitationListener does not seem to working. #36

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
InvitationListeners are dispatched in MultiUserChat.InvitationsMonitor.init().

in processPacket(), 
MUCUser mucUser = (MUCUser) packet.getExtension("x", 
"http://jabber.org/protocol/muc#user") 
throw a ClassCastException.
Because packet.getExtension() returns a instance of DefaultPacketExtension.

This logic needs a instance of MUCUser.
and a instance of MUCUser is made by MUCUserProvider.
But, MUCUserProvider was not used in asmack. (I used grep command)

Why? I don't understand. Is this InvitationListener not running still once?

Original issue reported on code.google.com by maim...@gmail.com on 28 Aug 2010 at 6:36

GoogleCodeExporter commented 8 years ago
I can run it!

XMPPConnection mConnection = new XMPPConnection(config);
mConnection.connect();
mConnection.login(login, password, resource);
ProviderManager pm = ProviderManager.getInstance();
pm.addExtensionProvider("x", "http://jabber.org/protocol/muc#user", new 
MUCUserProvider());
MultiUserChat.addInvitationListener(mConnection, mInvitationListener);  

Original comment by maim...@gmail.com on 28 Aug 2010 at 7:34

GoogleCodeExporter commented 8 years ago
Exactly, aSmack doesn't add package extensions per default. This is bad when 
you get started (as you need to lern how to register those) but it's good for 
production (no I don't want this hashtable monster extension!).

Good luck and happy coding :-)

PS: You should register your extensions ONCE BEFORE login / connect :-)

Original comment by rtreffer@gmail.com on 28 Aug 2010 at 8:11