use of org.eclipse.ecf.presence.im.IChatID in project ecf by eclipse.
the class ChatRoomMessageHandler method preChatRoomConnect.
public void preChatRoomConnect(IChatRoomContainer roomContainer, ID roomID) {
// retrieve our name
ID connectedID = container.getConnectedID();
botName = connectedID.getName();
IChatID chatID = (IChatID) connectedID.getAdapter(IChatID.class);
if (chatID != null) {
botName = chatID.getUsername();
}
messageSenders.put(roomID, roomContainer.getChatRoomMessageSender());
if (password != null) {
try {
sendMessage(IDFactory.getDefault().createStringID("nickserv"), "identify " + password);
} catch (IDCreateException e) {
}
}
}
use of org.eclipse.ecf.presence.im.IChatID in project ecf by eclipse.
the class ChatRoomManagerView method getUsernameFromID.
/**
* @return String username for given <code>targetID</code>
*/
public static String getUsernameFromID(ID targetID) {
IChatID chatID = (IChatID) targetID.getAdapter(IChatID.class);
if (chatID != null)
return chatID.getUsername();
try {
URI uri = new URI(targetID.getName());
String user = uri.getUserInfo();
return user == null ? targetID.getName() : user;
} catch (URISyntaxException e) {
String userAtHost = targetID.getName();
int atIndex = userAtHost.lastIndexOf(ATSIGN);
if (atIndex != -1)
userAtHost = userAtHost.substring(0, atIndex);
return userAtHost;
}
}
use of org.eclipse.ecf.presence.im.IChatID in project ecf by eclipse.
the class ChatSORobotApplication method handlePresence.
/**
* @since 2.0
*/
public void handlePresence(ID fromID, IPresence presence) {
System.out.println("handlePresence fromID=" + fromID + " presence=" + presence);
IChatID fromChatID = (IChatID) fromID.getAdapter(IChatID.class);
if (fromChatID != null) {
rosterUsers.put(fromChatID.getUsername() + "@" + fromChatID.getHostname(), fromID);
}
}
use of org.eclipse.ecf.presence.im.IChatID in project ecf by eclipse.
the class ChatRobotApplication method handlePresence.
/**
* @since 2.0
*/
public void handlePresence(ID fromID, IPresence presence) {
System.out.println("handlePresence fromID=" + fromID + " presence=" + presence);
IChatID fromChatID = (IChatID) fromID.getAdapter(IChatID.class);
if (fromChatID != null) {
rosterUsers.put(fromChatID.getUsername() + "@" + fromChatID.getHostname(), fromID);
}
}
use of org.eclipse.ecf.presence.im.IChatID in project ecf by eclipse.
the class IRCDatashareChannel method sendMessage.
public void sendMessage(ID receiver, byte[] message) throws ECFException {
// $NON-NLS-1$
Assert.isNotNull(receiver, "A receiver must be specified");
// retrieve the target's name
String name = receiver instanceof IChatID ? ((IChatID) receiver).getUsername() : receiver.getName();
// now create a string that is similar to our own ID, using the form
// username@irc.freenode.net:6667
StringBuffer buffer = new StringBuffer(name);
buffer.append('@').append(userId.getHost());
buffer.append(':').append(userId.getPort());
// now create a new ID
ID modifiedId = receiverNamespace.createInstance(new Object[] { buffer.toString() });
// send the message with the new ID
super.sendMessage(modifiedId, message);
}
Aggregations