Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [ecf-dev] Retrieving nickname from ID

Hi Tim,

Good idea.  I've added a new interface to the org.eclipse.ecf.presence API:

org.eclipse.ecf.presence.IChatID

public interface IChatID {
   /**
    * Get username for this ID
    * @return String username for ID
    */
   public String getUsername();
}

And I've implemented (for XMPPID, XMPPRoomID, and IRCID) this interface as an adapter off of ID...so the following will now work:

IChatID chatID = (IChatID) id.getAdapter(IChatID.class);
if (chatID != null) {
  String username = chatID.getUsername();
  ...use username here
}

This is checked in the source tree now (Sat 2:30pm pacific time). And by the time you get this email the javadocs on the website will likely be updated with the IChatID class.

Thanks for suggestion Tim.

Scott


Tim Terlegård wrote:
Hi,

In my chat app I add a message listener using this code:

chatroom.addMessageListener(new IMessageListener() {
    public void handleMessage(final ID from, final ID to,
                              final IMessageListener.Type type,
			      final String subject, final String msg) {
        XMPPID id = (XMPPID) from;
	chatUI.handleMessage(from.getUsername(), msg);
   }
});

I have to cast the ID to XMPPID to be able to use getUsername(). That
restricts my code to xmpp. What about introducing ChatID? It could be an
interface that XMPPID and IRCID implements.

Tim
_______________________________________________
ecf-dev mailing list
ecf-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/ecf-dev




Back to the top