Issue #2955 ignore duplicate session invites

Former-commit-id: a48b12b8aaeea250680c0726f72425eac170ecd7
This commit is contained in:
Brian Clements 2014-04-24 09:25:54 -05:00
parent df05a79d63
commit f888819646

View file

@ -19,6 +19,9 @@
**/ **/
package com.raytheon.uf.viz.collaboration.ui; package com.raytheon.uf.viz.collaboration.ui;
import java.util.HashSet;
import java.util.Set;
import org.eclipse.core.runtime.jobs.Job; import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Shell;
@ -71,6 +74,7 @@ import com.raytheon.viz.ui.views.CaveWorkbenchPageManager;
* Mar 06, 2014 2848 bclement moved SharedDisplaySessionMgr.joinSession call to InviteDialog * Mar 06, 2014 2848 bclement moved SharedDisplaySessionMgr.joinSession call to InviteDialog
* Apr 08, 2014 2785 mpduff removed preference listener * Apr 08, 2014 2785 mpduff removed preference listener
* Apr 11, 2014 2903 bclement added disconnect handler * Apr 11, 2014 2903 bclement added disconnect handler
* Apr 24, 2014 2955 bclement ignore duplicate session invites
* *
* </pre> * </pre>
* *
@ -91,6 +95,8 @@ public class ConnectionSubscriber {
private final DisconnectHandler disconnect = new DisconnectHandler(); private final DisconnectHandler disconnect = new DisconnectHandler();
private final Set<String> pendingInviteDialogs = new HashSet<String>();
private ConnectionSubscriber() { private ConnectionSubscriber() {
} }
@ -178,16 +184,53 @@ public class ConnectionSubscriber {
@Subscribe @Subscribe
public void handleInvitationEvent(final IVenueInvitationEvent event) { public void handleInvitationEvent(final IVenueInvitationEvent event) {
final String roomId = event.getRoomId().getFQName();
VizApp.runAsync(new Runnable() { VizApp.runAsync(new Runnable() {
@Override @Override
public void run() { public void run() {
Shell shell = new Shell(Display.getCurrent()); if (!invitePending(roomId)) {
InviteDialog inviteBox = new InviteDialog(shell, event); try {
if (!(Boolean) inviteBox.open()) { Shell shell = new Shell(Display.getCurrent());
return; InviteDialog inviteBox = new InviteDialog(shell, event);
if ((Boolean) inviteBox.open()) {
/* user accepted invite */
openSession(inviteBox);
}
} finally {
synchronized (pendingInviteDialogs) {
pendingInviteDialogs.remove(roomId);
}
}
} else {
statusHandler.debug("Ignoring duplicate session invite: "
+ roomId);
} }
}
/**
* @param roomId
* @return true if there is already an invitation pending for this
* room
*/
private boolean invitePending(String roomId) {
synchronized (pendingInviteDialogs) {
boolean pending = pendingInviteDialogs.contains(roomId);
if (!pending) {
/* immediately set to pending to ignore dup invites */
pendingInviteDialogs.add(roomId);
}
return pending;
}
}
/**
* Open session view after invite has been accepted
*
* @param inviteBox
*/
private void openSession(InviteDialog inviteBox) {
try { try {
IVenueSession session = inviteBox.getSession(); IVenueSession session = inviteBox.getSession();
if (inviteBox.isSharedDisplay()) { if (inviteBox.isSharedDisplay()) {