use of org.eclipse.ecf.presence.IIMMessageListener in project ecf by eclipse.
the class IRCAbstractContainer method fireChatRoomMessageEvent.
public void fireChatRoomMessageEvent(ID sender, String msg) {
for (Iterator i = msgListeners.iterator(); i.hasNext(); ) {
IIMMessageListener l = (IIMMessageListener) i.next();
l.handleMessageEvent(new ChatRoomMessageEvent(sender, new ChatRoomMessage(sender, targetID, msg)));
}
}
use of org.eclipse.ecf.presence.IIMMessageListener in project ecf by eclipse.
the class XMPPChatClient method setupPresence.
public void setupPresence() throws ECFException {
if (presence == null) {
presence = (IPresenceContainerAdapter) container.getAdapter(IPresenceContainerAdapter.class);
if (presence == null)
throw new ECFException("adapter is null");
sender = presence.getChatManager().getChatMessageSender();
presence.getChatManager().addMessageListener(new IIMMessageListener() {
public void handleMessageEvent(IIMMessageEvent messageEvent) {
if (messageEvent instanceof IChatMessageEvent) {
IChatMessage m = ((IChatMessageEvent) messageEvent).getChatMessage();
if (receiver != null) {
receiver.handleMessage(m);
}
}
}
});
if (presenceListener != null) {
presence.getRosterManager().addPresenceListener(presenceListener);
}
}
}
use of org.eclipse.ecf.presence.IIMMessageListener in project ecf by eclipse.
the class XMPPChatRoomContainerHelper method fireMessageListeners.
protected void fireMessageListeners(ID from, String body) {
List toNotify = null;
synchronized (messageListeners) {
toNotify = new ArrayList(messageListeners);
}
for (final Iterator i = toNotify.iterator(); i.hasNext(); ) {
final IIMMessageListener l = (IIMMessageListener) i.next();
l.handleMessageEvent(new ChatRoomMessageEvent(from, new ChatRoomMessage(from, roomID, body)));
}
}
use of org.eclipse.ecf.presence.IIMMessageListener in project ecf by eclipse.
the class ChatRoomManagerUI method setupNewView.
private void setupNewView() throws Exception {
IChatRoomInfo roomInfo = manager.getChatRoomInfo(null);
Assert.isNotNull(roomInfo, Messages.ChatRoomManagerUI_EXCEPTION_NO_ROOT_CHAT_ROOM_MANAGER);
final IChatRoomContainer managerChatRoom = roomInfo.createChatRoomContainer();
chatroomview.initializeWithManager(ChatRoomManagerView.getUsernameFromID(targetID), ChatRoomManagerView.getHostnameFromID(targetID), managerChatRoom, this, createChatRoomViewCloseListener());
chatroomview.setMessageRenderer(getDefaultMessageRenderer());
// Add listener for container, so that if the container is spontaneously
// disconnected,
// then we will be able to have the UI respond by making itself inactive
container.addListener(new IContainerListener() {
public void handleEvent(final IContainerEvent evt) {
Display.getDefault().syncExec(new Runnable() {
public void run() {
if (evt instanceof IContainerDisconnectedEvent || evt instanceof IContainerEjectedEvent) {
final ID departedContainerID = ((evt instanceof IContainerDisconnectedEvent) ? ((IContainerDisconnectedEvent) evt).getTargetID() : ((IContainerEjectedEvent) evt).getTargetID());
ID connectedID = targetID;
if (connectedID == null || connectedID.equals(departedContainerID)) {
chatroomview.disconnected();
isContainerConnected = false;
}
} else if (evt instanceof IContainerConnectedEvent) {
isContainerConnected = true;
chatroomview.setEnabled(true);
String[] roomsForTarget = getRoomsForTarget();
for (int i = 0; i < roomsForTarget.length; i++) {
IChatRoomInfo info = manager.getChatRoomInfo(roomsForTarget[i]);
chatroomview.joinRoom(info, getPasswordForChatRoomConnect(info));
}
}
}
});
}
});
// Add listeners so that the new chat room gets
// asynch notifications of various relevant chat room events
managerChatRoom.addMessageListener(new IIMMessageListener() {
public void handleMessageEvent(IIMMessageEvent messageEvent) {
if (messageEvent instanceof IChatRoomMessageEvent) {
IChatRoomMessage m = ((IChatRoomMessageEvent) messageEvent).getChatRoomMessage();
chatroomview.handleMessage(m.getFromID(), m.getMessage());
} else if (messageEvent instanceof IChatMessageEvent) {
final IChatMessage chatMessage = ((IChatMessageEvent) messageEvent).getChatMessage();
chatroomview.handleChatMessage(chatMessage);
}
}
});
}
use of org.eclipse.ecf.presence.IIMMessageListener in project ecf by eclipse.
the class XMPPChatRoomClient method setupPresenceAdapter.
protected void setupPresenceAdapter() {
// Get presence adapter off of container
presence = (IPresenceContainerAdapter) container.getAdapter(IPresenceContainerAdapter.class);
// Get sender interface
sender = presence.getChatManager().getChatMessageSender();
// Setup message requestListener to handle incoming messages
presence.getChatManager().addMessageListener(new IIMMessageListener() {
public void handleMessageEvent(IIMMessageEvent messageEvent) {
if (messageEvent instanceof IChatMessageEvent) {
final IChatMessage m = ((IChatMessageEvent) messageEvent).getChatMessage();
receiver.handleMessage(m);
}
}
});
}
Aggregations