[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Creating a generic chatroom ID is hard, too hard IMHO. We talked about
util methods, but should it really be so hard in the core API?
I couldn't come up with a perfect solution. I've come up with 3 possible
solutions. If you want to create a chatroom ID right now you do something
like this:
ID chatRoomID =
    IDFactory.getDefault().createID(chatroom.getConnectNamespace(),
    new Object[] {"user", "host", "domain", "room", "nickname"});
It took quite a while before I realized how to create that ID correctly.
Possible solution I come up with:
1)
class XMPPChatManager implements IChatManager {
   public void join(String room, String nick) {
      IChatRoomContainer chat = createChatRoomContainer();
      ID id = new XMPPRoomID(chat.getConnectedNamespace(),
                             xmppConnection, "room", "nick");
      chat.connect(id, null);
      return chat;
   }
}
It makes it easier to join a chatroom and it hides the ID creation, but
it's still hard to create a generic chatroom ID using the core API.
2)
IChatRoomContainer chat = chatManager.createChatRoomContainer();
IChatRoomIDFactory f = chat.getAdapter(IChatRoomIDFactory.class);
f.createID("room", "nick");
3)
class XMPPRoomNamespace extends ChatRoomNamespace {
   public ID createInstance(String room, String nick) {
      return createInstance(...);
   }
}
ChatRoomNamespace chat = (ChatRoomNamespace) container.getConnectedNamespace();
IChatRoomID chatRoomID = chat.createInstance("room", "nick");
But the chatRoomID still miss information about username and domain.
I like solution 2, but I suspect it's not the Eclipse way?
Tim