Join MUC through Plugin

I have a plugin that receives events/requests as a http servelet. These requests include setting a users presense and joining a MUC room.

I have however run into a wall here. As far as I could find out, a user is joined into a MUC by calling MUCRoom.joinRoom. One of the parameters is a LocalMUCUser. However, there is no way that I can find of either retreiving a LocalMUCUser or constructing one.

Am I missing something?

Is there another way that I should use to cause a user to join a MUC from a plugin?

See http://www.igniterealtime.org/community/message/191207.

From the source code it appears that one could fake a room join by sending a fake message

MUCRoom room = mucService.getChatRoom(roomName);
JID userjid = new JID(userName, server, "Server");
MultiUserChatService mucService = mucManager.getMultiUserChatServices().get(0);
               
Message cheat = new Message();
cheat.setTo(room.getJID());
cheat.setFrom(userjid);
mucService.processPacket(cheat);

Now I just need to figure out what should go in the message. Has any one tried this way from a plugin before?

I think with:

/** * If a local groupchat is available enter a chatroom. * * @param realJID The JID of the entity which wants to join a chat. * @param roomName The name of a chatroom. * @param nickname The nickname of the entity within the chatroom. * @return The JID of the new participant in the chatroom or null. */
public JID joinChatRoom(JID realJID, String roomName, String nickname) {
  JID mucOccupant = null;
  XMPPServer server = XMPPServer.getInstance();
  MultiUserChatManager mucManager = server.getMultiUserChatManager();
  if (mucManager.getMultiUserChatServicesCount() > 0) {
    MultiUserChatService mucService = mucManager.getMultiUserChatServices().get(0);
    mucOccupant = new JID(roomName,mucService.getServiceDomain(),nickname);
    Presence presence = new Presence();
    presence.setTo(mucOccupant);
    presence.setFrom(realJID);
    presence.addChildElement("x", "http://jabber.org/protocol/muc");
    mucService.processPacket(presence);
  }
  return mucOccupant;
}

it should be possible to join a chat room, but you should also handle the replys to the realJID from the Multi-User Chat service like presence broadcasts for room members, errors which maybe occur or the status code 201 for creating a new room (see XEP-0045).

But I think this is more a workaround for joining a chatroom, it should be better accessible through the API.