charoom is deleted when sending a messge to chatroom
I have a situation where when I programmatically enter a chat room and do not exit the chatroom when program ends the chatroom is deleted. I commented the line "chatRoom.exit();" out sand then the chatroom is deleted. client.connect(); client.login("xxxxxxxx", "xxxxxxx"); MultiUserChatManager multiUserChatManager = client.getManager(MultiUserChatManager.class); Jid chatRoomJid = Jid.of(chatRoomName);
ChatRoom chatRoom = multiUserChatManager.createChatRoom(chatRoomJid);
chatRoom.enter(nick);
chatRoom.sendMessage(message);
//chatRoom.exit();
client.close();
Comments (4)
-
repo owner -
thanks, I created the chatroom outside of the Java code (using Jabber client). I actually only want to join the room and send messages. the library does not allow just join, you have to create a chatroom and according to your documentation this is valid for both new chatrooms and to join an existing room. If I add the chatRoom.exit(); line before closing the client then the chatroom is left undeleted. If I remove the chatRoom.exit(); line then the chatroom is deleted.
-
repo owner exit()
simply sends an unavailable presence to the chat room in accordance with the specification.Please also note, that
enter()
andsendMessage()
are asynchronous methods (they returnFuture<Void>
). If youclose()
too early, the unavailable presence might not have been sent.In any case, I have no idea, why the room is deleted (on the server, right?), if you don't exit gracefully with unavailable presence (
exit()
). Maybe the server has a timeout and deletes them later?If you want to block (wait until sent, or until exited), try this:
chatRoom.sendMessage("Hi").get(); chatRoom.exit().get();
To be clear:
multiUserChatManager.createChatRoom(chatRoomJid);
only creates aChatRoom
instance locally, so you can work with it. -
repo owner Is this still an issue?
- Log in to comment
I guess your XMPP server deletes the chat room if the room is empty (which it is, if you end the program or exit). Try to configure it as permanent room: