[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[ecf-dev] Chatroom ID

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 =
    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:


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.


IChatRoomContainer chat = chatManager.createChatRoomContainer();
IChatRoomIDFactory f = chat.getAdapter(IChatRoomIDFactory.class);
f.createID("room", "nick");


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?