So I built what is an instant messaging bot using the Smack API and the Openfire XMPP server. Doing it is pretty simple of you read the documentation and Smack’s developer notes. The bot relies on a queue-like object that Smack gives you called a PacketCollector. All you need to do is log in to the server, and let the packet collector wait for incoming messages. Clearly, you need to respond to the messages and use thread tools to do the waiting and all, but in general, the effort is relatively straightforward.
Tag: Openfire
Another observation regarding XMPP multi-user chat (aka chat-rooms) to follow on my previous entry. This one is also an odd one.
It appears that Openfire uses all-lowercase names for multi-user chat rooms. So if your room’s name is “myRoom”, it will be saved as “myroom”.
Could not find anything to require this in the XMPP specifications for multi-user chat.
Oddness.
UPDATE:
This is apparently the way it is supposed to be according to the XMPP protocol or as explained to me on the Openfire dev boards.
I encountered two interesting points when working with the Openfire XMPP server and the Smack API, both from IgniteRealtime.
- After joining a Multi-User Chat (MUC) independently, without invite, I was forbidden (e.g. error 403) from finding out who the administrators or owners of the room were. I could not find anything about this in the documentation.
The workaround was not too bad: apparently the methodgetOccupant(
allows you to get an) Occupant
object which does hold affiliation and can report admin rights. - In some situations – not sure when yet – the owner of an MUC was able to grant another user admin status by just using his/her nickname, without using the full JID. That is
grantAdmin("nickname")
worked just as well asgrantAdmin("nickname@conference.server")
. Nonetheless, when trying to use the method getOccupant() as mentioned above, the full JID form worked while the nickname-only one failed.
I am using Smack 3.0.4 and Openfire 3.5.2. Weird.