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();
}
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());
}
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();
}
}
}
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);
}
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();
}
Aggregations