Search in sources :

Example 6 with IChatMessage

use of org.eclipse.ecf.presence.im.IChatMessage in project ecf by eclipse.

the class AbstractChatTest method testSendMessageProperties.

public void testSendMessageProperties() throws Exception {
    final Map sendprops = new HashMap();
    sendprops.put("prop2", "that");
    // Send the whole thing
    chat0.getChatMessageSender().sendChatMessage(getClient(1).getConnectedID(), null, IChatMessage.Type.CHAT, null, null, sendprops);
    sleep(SLEEPTIME);
    assertHasEvent(receivedChatMessages, IChatMessage.class);
    final IChatMessage message = (IChatMessage) receivedChatMessages.get(0);
    assertNull(message.getSubject());
    assertTrue(message.getBody().equals(""));
    assertTrue(message.getType().equals(IChatMessage.Type.CHAT));
    final Map props = message.getProperties();
    assertNotNull(props);
    assertTrue(props.size() == 1);
    final String val = (String) props.get("prop2");
    assertNotNull(val);
    assertEquals(val, "that");
}
Also used : IChatMessage(org.eclipse.ecf.presence.im.IChatMessage) HashMap(java.util.HashMap) Map(java.util.Map) HashMap(java.util.HashMap)

Example 7 with IChatMessage

use of org.eclipse.ecf.presence.im.IChatMessage in project ecf by eclipse.

the class AbstractChatTest method testSendIM2.

public void testSendIM2() throws Exception {
    final Map sendprops = new HashMap();
    sendprops.put("prop1", "this");
    final ID sendthreadid = IDFactory.getDefault().createStringID("thread1");
    // Send the whole thing
    chat0.getChatMessageSender().sendChatMessage(getClient(1).getConnectedID(), sendthreadid, IChatMessage.Type.CHAT, "subject1", "uvwxyz", sendprops);
    sleep(SLEEPTIME);
    assertHasEvent(receivedChatMessages, IChatMessage.class);
    final IChatMessage message = (IChatMessage) receivedChatMessages.get(0);
    // For some reason, the smack library doesn't seem to get this right.
    // assertTrue(message.getThreadID().equals(sendthreadid));
    assertTrue(message.getSubject().equals("subject1"));
    assertTrue(message.getBody().equals("uvwxyz"));
    assertTrue(message.getType().equals(IChatMessage.Type.CHAT));
    final Map props = message.getProperties();
    assertNotNull(props);
    assertTrue(props.size() == 1);
    final String val = (String) props.get("prop1");
    assertNotNull(val);
    assertEquals(val, "this");
}
Also used : IChatMessage(org.eclipse.ecf.presence.im.IChatMessage) HashMap(java.util.HashMap) ID(org.eclipse.ecf.core.identity.ID) Map(java.util.Map) HashMap(java.util.HashMap)

Example 8 with IChatMessage

use of org.eclipse.ecf.presence.im.IChatMessage in project ecf by eclipse.

the class IMBot method handleMessageEvent.

public void handleMessageEvent(IIMMessageEvent event) {
    if (event instanceof IChatMessageEvent) {
        IChatMessageEvent imEvent = (IChatMessageEvent) event;
        IChatMessage message = imEvent.getChatMessage();
        List commands = bot.getCommands();
        for (int i = 0; i < commands.size(); i++) {
            IIMMessageHandlerEntry entry = (IIMMessageHandlerEntry) commands.get(i);
            entry.handleIMMessage(message);
        }
    }
}
Also used : IChatMessage(org.eclipse.ecf.presence.im.IChatMessage) IIMMessageHandlerEntry(org.eclipse.ecf.presence.bot.IIMMessageHandlerEntry) IChatMessageEvent(org.eclipse.ecf.presence.im.IChatMessageEvent) List(java.util.List)

Aggregations

IChatMessage (org.eclipse.ecf.presence.im.IChatMessage)8 IChatMessageEvent (org.eclipse.ecf.presence.im.IChatMessageEvent)4 HashMap (java.util.HashMap)3 Map (java.util.Map)3 IIMMessageEvent (org.eclipse.ecf.presence.IIMMessageEvent)3 IIMMessageListener (org.eclipse.ecf.presence.IIMMessageListener)3 ID (org.eclipse.ecf.core.identity.ID)2 List (java.util.List)1 IContainerListener (org.eclipse.ecf.core.IContainerListener)1 ECFException (org.eclipse.ecf.core.util.ECFException)1 IIMMessageHandlerEntry (org.eclipse.ecf.presence.bot.IIMMessageHandlerEntry)1 MessagesView (org.eclipse.ecf.presence.ui.MessagesView)1 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)1 PartInitException (org.eclipse.ui.PartInitException)1 IWorkbenchSiteProgressService (org.eclipse.ui.progress.IWorkbenchSiteProgressService)1