powered by Jive Software

How do I access a MUC ROOM

I’'m writing a plugin for the jive 2.1.3 server. One of the things I need to do is generate internally a room, configure the room to non-default settings, and populate it with a bot program to monitor activity in the room.

Well using the smack api I ran into a bit of problem trying to do this properly (since it is actually 2+ connections being created since there is already a bot in 1 room and depending on the command it is instructed depends on which server it creates the new room on so it has to login to the other server, create a room on the other server, and monitor activity on that new room on the other server).

Hmm. That might not have made sense but in any event what I would like to get access to is MultiUserChatServer from inside the messenger api rather then trying to do this as bots with the smack api since it is already a plugin inside the messenger application. How do I gain access to a MultiUserChatServer (both new and already existing ones). I found nothing in the org.jivesoftware.messenger.muc that indiciated it might help me out in that area. And I found nothing similtar to the Managers used to provide access for other things like global plugins, accounts, and other things. Any clues would be helpful.

Hey Sejal,

I’'m a bit lost in what you are trying to do here. IMO, the simplest and more portable solution is to use Smack for what you are trying to do. You can try creating the room and configure it from the server but it is a more complex way to go.

If you decide to go with Smack let us know what kind of problems you are having. If you want to follow the server-side approach then you have two options for creating and configuring the room.

Option 1: Access the MUC API

You can get the MultiUserChatServer instance using XMPPServer.getInstance().getMultiUserChatServer(). Once you have the MultiUserChatServer you will be able to create and configure a room. Take a look at muc-room-edit-form.jsp for an example on how to do this.

Option 2: Simulate client packets from the server

Messenger uses the Whack library that provides some high-level packets for MUC. You can use JoinRoom to join/create a room, RoomConfiguration for configuring the room and LeaveRoom for leaving the room. Since you are going to be sending packets, you will need to have a JID as the sender of those packets. If you are going to create a component you can use the component’'s JID as the sender or you can try creating a virtual user inside the component scope.

In order to monitor the room activity you need to be an occupant of the room. This means that option 2 is your best shot since you can use the sender of the packets as a room occupant.

Hope that helps.


– Gato

Thanks gato,

I’‘ll spend today trying the server-side approach and let you know how it works out for me. I’'ll go ahead and try to better explain my ramblings from earlier though

We have 6 servers. Each will have an instance of jives running on them. They will of course share and ldap server for accessing user accounts (have to register new users through the web portal).

What will happen is that we will be using these to support game messaging. We will have 3 to 5 main lobby areas for each type of game we throw out. In each of these lobbies will be a bot that will provide people who ask with a list of all the rooms that have actual match play going on within them. It is also responsible for creating new match play rooms when rooms run out or somebody wants a private match with another specific person or whatever (depending on server load).

Inside each of the match rooms themselves, we have another referee bot that is managing the game going on in that room. Instructions get sent to the referee and then the referee broadcasts the results to the room and everyone (players and observers of the game) update themselves accordingly.

Right now I have an implementation that does most of this. There are however issues with both lobby and referee boths wanting to leave the room the instant they join them and other times getting randomly stuck when trying to configure the room getting either 400 errors (whatever that is), no response from server, or Missing acknowledge of room creation exceptions. Thus since it looked like the room configuration stuff is the source of all the problems, I wanted to try and generate those rooms using the messengers internal api instead and just have these bots simply join as a normal owner bot without having to worry about configuring the room from their high level api.

How does one change helpful to answer btw? I accidentally clicked helpful and now there is no way for me to remove it or upgrade it

Hey Sejal,

That is a very interesting usage of XMPP. Are you going to use different domain names for each server? Will users in different servers need to communicate? We are planning some kind of clustering solution that will let you scale to several hundreds of thousands of connections using only one domain.

Regarding changing from “helpful” to “correct”: It is not possible in the current version but it is planned for the next version of Jive Forums. Thanks for the enhancement request. BTW, since this is a new answer you have now another chance to mark this answer as correct though it is not the previous answer.


– Gato

Thank you. I do enjoy finding new ways to be creative hehe. to answer your questions

  • No all 6 servers will be using the same domain names. Each server will be setup with 2 names. 1 is the direct access to a particular server name and the other is the name that will be used by the load balancer in front of it. All of the users are registered as the shared domain name though.

  • Users on different servers need only the presence information (at this time) and do not need communication capabilities outside of the current room they are in. In order to resolve the presence information problem, I wrote a plugin that would upon request spit out the presence status for everyone on that server and we have a servlet that will consolidate the results of all the servers and cache them (and periodically poll them for updates every 10 - 90 seconds depending on the cpu usage of each server during the last poll.

  • Do you have any kind of eta on when a prototype of that clustering solution will be available. They really do want to have the private messaging capabilities as well for this product as a phase two thing. I’'ve been getting them to push back and have been considering using a database/offline storage combination in order to handle that. However, if you are working on a true and proper clustering solution then that would be awesome. Would also allow me to not hack a solution around the presence information as well

Now for some additional questions

What are 400, 401, and 404 errors (from the xmpp error codes not webservers )

I get them a lot when trying to develop these things. It feels like the 404 is whenever I don’'t configure a room using the smack api. The 400 I get a lot whenever I try to get the configuration form from a room in order to try and configure a room. 401 I forgot how I get those but I get those a lot as well with the smack api.

Nevermind my 400, 401, 404 problems.

I finally figured out that the reason the rooms were not getting configured (well some where and others were not) is because you cannot have rooms with capital letters in them.

Thus if i tried to create myRoom it would never allow me to configure the room with smack.

If I however tried to create myroom it would work perfectly. Thus i’'ve just done a tolower on all room requests now and my problem is solved.

  • Do you have any kind of eta on when a prototype of

that clustering solution will be available.

Unfortunately I don’'t have any accurate estimation for this feature though we are highly interested in it. We are now focused on getting s2s and external component support out which are very important features too. If you are willing to work with us in the clustering solution just drop me an email.


– Gato