Hi mrbvo,
If I’‘m not mistaken, you are actually refering to the problem mentioned in your previous thread, aren’‘t you? IMHO, Justin’‘s source code perhaps didn’‘t work the way you wanted because, the way I see it, you will still have to restart your wildfire every time you make changes in the MUC tables. You have successfully been able to add users by modifying the UserService plugin, but you’'re still not able to join the room automatically and update the MUC tables on the fly, right?
Ryan was right about not to temper the database directly particularly with the MUC tables. Additionally, the API doesn’'t provide a simple approach of how to auto-join user in MUC rooms. It seems to me like the present code allows joining a room only through direct user interaction.
So, if you want to auto-join, you’‘ll have to simulate user interaction. That’‘s how I figured it out through MUC source code. I did mentioned in your last thread of how you could go about it but perhaps you didn’‘t try it. Here’'s an edited copy (simplified, no import & no error checking) of my last codes, in case you want to reconsider trying:
public void createUser(String username, String password, String name, String email, String roomName) throws UserAlreadyExistsException{
XMPPServer server = XMPPServer.getInstance();
UserManager userManager = server.getUserManager();
String localhost = server.getServerInfo().getName();
MultiUserChatServer multiUserChatServer = server.getMultiUserChatServer();
Presence presence;
MUCUser mucuser;
MUCRoom room;
MUCRole role; userManager.createUser(username, password, name, email); /* Simulate JEP-45 user enter room case */
presence = new Presence();
presence.setFrom(username + "@" + localhost + "/" + "some_resource");
presence.setTo(roomname + "@" + mucUserChatServer.getServiceDomain() + "/" + username);
presence.addChildElement("x", "http://jabber.org/protocol/muc"); /* This will create muc user if it''s not created yet. Don''t get confused with userManager.createUser above. This new muc user creation is an abstract user needed within a MultiUserChatServer instance */
mucUser = multiUserChatServer.getChatUser(presence.getFrom()); /* This will create the room if it''s not created yet. */
room = multiUserChatServer.getChatRoom(roomName, presence.getFrom()); /* joinRoom (String, String, HistoryRequest, MUCUser, Presence) */
role = room.joinRoom(username, null, null, mucUser, presence.createCopy());
room.unlock(role); /* Make sure it''s saved in the database if you want it to be persistant */
room.setPersistent(true);
room.saveToDB();
}
Message was edited by: aznidin