Search in sources :

Example 1 with Message

use of jetbrains.communicator.core.dispatcher.Message in project intellij-plugins by JetBrains.

the class AbstractMessageDispatcherTest method testPersistency.

public void testPersistency() throws Exception {
    Message failedMessage = new P2PNetworkMessage("foo", "foo2", new String[] { "test" });
    myDispatcher.performDispatch(myUser, failedMessage);
    myDispatcher.save();
    AbstractMessageDispatcher dispatcher = createDispatcher();
    assertEquals("queue should persist", 1, dispatcher.getPendingMessages(myUser).length);
    Message message = dispatcher.getPendingMessages(myUser)[0];
    assertTrue("queue should persist", message instanceof P2PNetworkMessage);
    assertEquals("test", ((P2PNetworkMessage) message).getParameters()[0]);
    dispatcher.dispose();
}
Also used : Message(jetbrains.communicator.core.dispatcher.Message) P2PNetworkMessage(jetbrains.communicator.p2p.commands.P2PNetworkMessage) MockMessage(jetbrains.communicator.mock.MockMessage) P2PNetworkMessage(jetbrains.communicator.p2p.commands.P2PNetworkMessage)

Example 2 with Message

use of jetbrains.communicator.core.dispatcher.Message in project intellij-plugins by JetBrains.

the class LocalMessageDispatcherTest method testTransportEvent.

public void testTransportEvent() throws Exception {
    MockTransport mockTransport = new MockTransport();
    MockMessage localMessage = new MockMessage();
    MockMessage localMessage1 = new MockMessage();
    myIdeFacade.setReturnedMessage(localMessage);
    getBroadcaster().fireEvent(new TransportEvent(mockTransport, "user") {
    });
    myIdeFacade.setReturnedMessage(localMessage1);
    getBroadcaster().fireEvent(new TransportEvent(mockTransport, "user") {
    });
    Message[] pendingMessages = myDispatcher.getPendingMessages(myUser);
    assertEquals("Expect a local localMessages as a result to TransportEvent", 2, pendingMessages.length);
    assertSame(localMessage, pendingMessages[0]);
    assertSame(localMessage1, pendingMessages[1]);
    assertEquals("", localMessage.getLog());
}
Also used : TransportEvent(jetbrains.communicator.core.transport.TransportEvent) MockMessage(jetbrains.communicator.mock.MockMessage) Message(jetbrains.communicator.core.dispatcher.Message) LocalMessage(jetbrains.communicator.core.dispatcher.LocalMessage) MockTransport(jetbrains.communicator.mock.MockTransport) MockMessage(jetbrains.communicator.mock.MockMessage)

Example 3 with Message

use of jetbrains.communicator.core.dispatcher.Message in project intellij-plugins by JetBrains.

the class UserTree method deliverLocalMessage.

private void deliverLocalMessage(User user, TreePath path, MouseEvent e) {
    Message[] pendingMessages = myLocalMessageDispatcher.getPendingMessages(user);
    if (pendingMessages.length > 0) {
        IdeaLocalMessage message = (IdeaLocalMessage) pendingMessages[0];
        if (myLocalMessageDispatcher.sendNow(user, message)) {
            myDelivered = true;
            e.consume();
            ((MyTreeUI) getUI()).invalidatePath(path);
            treeDidChange();
        }
    }
}
Also used : IdeaLocalMessage(jetbrains.communicator.idea.IdeaLocalMessage) Message(jetbrains.communicator.core.dispatcher.Message) IdeaLocalMessage(jetbrains.communicator.idea.IdeaLocalMessage)

Example 4 with Message

use of jetbrains.communicator.core.dispatcher.Message in project intellij-plugins by JetBrains.

the class UserTree method getToolTipText.

public String getToolTipText(MouseEvent e) {
    TreePath pathForLocation = getPathForLocation(e.getX(), e.getY());
    if (pathForLocation != null) {
        Object userObject = TreeUtils.getUserObject(pathForLocation);
        if (userObject instanceof User) {
            User user = (User) userObject;
            StringBuffer result = new StringBuffer();
            if (!user.getName().equals(user.getDisplayName())) {
                result.append(StringUtil.getMsg("user.tooltip", user.getName())).append("\n");
            }
            Message[] pendingMessages = myLocalMessageDispatcher.getPendingMessages(user);
            if (pendingMessages.length > 0) {
                IdeaLocalMessage ideaLocalMessage = (IdeaLocalMessage) pendingMessages[0];
                result.append(ideaLocalMessage.getTitle());
                if (result.length() > 0 && ideaLocalMessage.getComment().length() > 0) {
                    result.append(": ");
                }
                result.append(ideaLocalMessage.getComment());
            }
            return result.length() == 0 ? super.getToolTipText(e) : result.toString();
        }
    }
    return super.getToolTipText(e);
}
Also used : IdeaLocalMessage(jetbrains.communicator.idea.IdeaLocalMessage) User(jetbrains.communicator.core.users.User) TreePath(javax.swing.tree.TreePath) Message(jetbrains.communicator.core.dispatcher.Message) IdeaLocalMessage(jetbrains.communicator.idea.IdeaLocalMessage)

Example 5 with Message

use of jetbrains.communicator.core.dispatcher.Message in project intellij-plugins by JetBrains.

the class AsyncMessageDispatcherImpl method dispatchAllMessages.

private void dispatchAllMessages() {
    User[] usersWithMessages = getUsersWithMessages();
    for (int i = 0; i < usersWithMessages.length && isRunning(); i++) {
        User user = usersWithMessages[i];
        Message[] pendingMessages = getPendingMessages(user);
        for (int j = 0; j < pendingMessages.length && isRunning(); j++) {
            performDispatch(user, pendingMessages[j]);
        }
    }
    save();
}
Also used : User(jetbrains.communicator.core.users.User) Message(jetbrains.communicator.core.dispatcher.Message)

Aggregations

Message (jetbrains.communicator.core.dispatcher.Message)5 User (jetbrains.communicator.core.users.User)2 IdeaLocalMessage (jetbrains.communicator.idea.IdeaLocalMessage)2 MockMessage (jetbrains.communicator.mock.MockMessage)2 TreePath (javax.swing.tree.TreePath)1 LocalMessage (jetbrains.communicator.core.dispatcher.LocalMessage)1 TransportEvent (jetbrains.communicator.core.transport.TransportEvent)1 MockTransport (jetbrains.communicator.mock.MockTransport)1 P2PNetworkMessage (jetbrains.communicator.p2p.commands.P2PNetworkMessage)1