Issue #427 fix peer to peer
Change-Id: Iae7f0d4c5f3f28360a957768fa755809fe47c171 Former-commit-id:38dcb603b2
[formerly8da43825d0
] [formerly38dcb603b2
[formerly8da43825d0
] [formerly62c5527e17
[formerly b8ca7f7c0d329c1d7bb527317fc89794ea4dbac0]]] Former-commit-id:62c5527e17
Former-commit-id:26f41aa6ad
[formerly7fdc45a275
] Former-commit-id:3b749bfff8
This commit is contained in:
parent
f0e56aa8b8
commit
4fa7c6a38f
8 changed files with 47 additions and 28 deletions
|
@ -37,6 +37,7 @@ import org.eclipse.ui.IViewReference;
|
|||
import org.eclipse.ui.IWorkbench;
|
||||
import org.eclipse.ui.IWorkbenchListener;
|
||||
import org.eclipse.ui.IWorkbenchPage;
|
||||
import org.eclipse.ui.IWorkbenchPart;
|
||||
import org.eclipse.ui.PartInitException;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
|
||||
|
@ -622,15 +623,17 @@ public class CollaborationDataManager implements IRosterEventSubscriber {
|
|||
|
||||
@Override
|
||||
public void run() {
|
||||
String id = message.getFrom().getFQName();
|
||||
IQualifiedID peer = message.getFrom();
|
||||
for (IViewReference ref : PlatformUI.getWorkbench()
|
||||
.getActiveWorkbenchWindow().getActivePage()
|
||||
.getViewReferences()) {
|
||||
if (id.equals(ref.getSecondaryId())) {
|
||||
PeerToPeerView p2pView = (PeerToPeerView) ref
|
||||
.getView(false);
|
||||
p2pView.appendMessage(message);
|
||||
return;
|
||||
IWorkbenchPart part = ref.getPart(false);
|
||||
if (part != null && part instanceof PeerToPeerView) {
|
||||
PeerToPeerView p2pView = (PeerToPeerView) part;
|
||||
if (p2pView.getPeer().equals(peer)) {
|
||||
p2pView.appendMessage(message);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
|
@ -638,14 +641,13 @@ public class CollaborationDataManager implements IRosterEventSubscriber {
|
|||
.getWorkbench()
|
||||
.getActiveWorkbenchWindow()
|
||||
.getActivePage()
|
||||
.showView(PeerToPeerView.ID, id,
|
||||
.showView(PeerToPeerView.ID, peer.getFQName(),
|
||||
IWorkbenchPage.VIEW_ACTIVATE);
|
||||
p2pView.setPeer(peer);
|
||||
p2pView.appendMessage(message);
|
||||
} catch (PartInitException e) {
|
||||
// TODO Auto-generated catch block. Please revise as
|
||||
// appropriate.
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
e.getLocalizedMessage(), e);
|
||||
"Error opening peer to peer view", e);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -82,8 +82,10 @@ import com.raytheon.uf.viz.collaboration.comm.identity.info.IVenueInfo;
|
|||
import com.raytheon.uf.viz.collaboration.comm.identity.roster.IRosterEntry;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.roster.IRosterGroup;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.roster.IRosterManager;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID;
|
||||
import com.raytheon.uf.viz.collaboration.comm.provider.Tools;
|
||||
import com.raytheon.uf.viz.collaboration.comm.provider.session.CollaborationConnection;
|
||||
import com.raytheon.uf.viz.collaboration.comm.provider.user.IDConverter;
|
||||
import com.raytheon.uf.viz.collaboration.data.CollaborationDataManager;
|
||||
import com.raytheon.uf.viz.collaboration.data.CollaborationGroup;
|
||||
import com.raytheon.uf.viz.collaboration.data.CollaborationNode;
|
||||
|
@ -274,7 +276,7 @@ public class CollaborationGroupView extends ViewPart implements IPartListener {
|
|||
peerToPeerChatAction = new Action("Chat") {
|
||||
@Override
|
||||
public void run() {
|
||||
createP2PChat(getId());
|
||||
createP2PChat(IDConverter.convertFrom(getId()));
|
||||
}
|
||||
};
|
||||
peerToPeerChatAction.setImageDescriptor(IconUtil.getImageDescriptor(
|
||||
|
@ -722,15 +724,15 @@ public class CollaborationGroupView extends ViewPart implements IPartListener {
|
|||
*
|
||||
* @param user
|
||||
*/
|
||||
private void createP2PChat(String user) {
|
||||
System.err.println("createPrivateChat with " + user);
|
||||
private void createP2PChat(IQualifiedID peer) {
|
||||
try {
|
||||
PlatformUI
|
||||
PeerToPeerView p2pView = (PeerToPeerView) PlatformUI
|
||||
.getWorkbench()
|
||||
.getActiveWorkbenchWindow()
|
||||
.getActivePage()
|
||||
.showView(PeerToPeerView.ID, user,
|
||||
.showView(PeerToPeerView.ID, peer.getFQName(),
|
||||
IWorkbenchPage.VIEW_ACTIVATE);
|
||||
p2pView.setPeer(peer);
|
||||
} catch (PartInitException e) {
|
||||
statusHandler.handle(Priority.PROBLEM, "Unable to open chat", e);
|
||||
}
|
||||
|
@ -1153,7 +1155,7 @@ public class CollaborationGroupView extends ViewPart implements IPartListener {
|
|||
String loginUserId = CollaborationDataManager
|
||||
.getInstance().getLoginId();
|
||||
if (loginUserId.equals(node.getId()) == false) {
|
||||
createP2PChat(node.getId());
|
||||
createP2PChat(IDConverter.convertFrom(node.getId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
|
|||
import com.raytheon.uf.viz.collaboration.comm.identity.CollaborationException;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.IPeerToPeer;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.listener.IMessageListener;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID;
|
||||
import com.raytheon.uf.viz.collaboration.data.CollaborationDataManager;
|
||||
|
||||
/**
|
||||
|
@ -58,6 +59,8 @@ public class PeerToPeerView extends AbstractSessionView {
|
|||
|
||||
protected IMessageListener messageListener;
|
||||
|
||||
private IQualifiedID peer;
|
||||
|
||||
public PeerToPeerView() {
|
||||
super();
|
||||
}
|
||||
|
@ -157,7 +160,6 @@ public class PeerToPeerView extends AbstractSessionView {
|
|||
* ()
|
||||
*/
|
||||
public void sendMessage() {
|
||||
String toUser = getViewSite().getSecondaryId();
|
||||
String message = getComposedMessage();
|
||||
if (message.length() > 0) {
|
||||
try {
|
||||
|
@ -165,7 +167,7 @@ public class PeerToPeerView extends AbstractSessionView {
|
|||
.getInstance();
|
||||
IPeerToPeer p2p = (IPeerToPeer) manager.getSessionManager()
|
||||
.getPeerToPeerSession();
|
||||
p2p.sendPeerToPeer(toUser, message);
|
||||
p2p.sendPeerToPeer(peer, message);
|
||||
appendMessage(manager.getLoginId(), null,
|
||||
System.currentTimeMillis(), message);
|
||||
} catch (CollaborationException e) {
|
||||
|
@ -191,4 +193,12 @@ public class PeerToPeerView extends AbstractSessionView {
|
|||
protected String getSessionName() {
|
||||
return getViewSite().getSecondaryId();
|
||||
}
|
||||
|
||||
public void setPeer(IQualifiedID peer) {
|
||||
this.peer = peer;
|
||||
}
|
||||
|
||||
public IQualifiedID getPeer() {
|
||||
return peer;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -142,6 +142,8 @@ public class SessionView extends AbstractSessionView {
|
|||
CollaborationConnection sessionManager = CollaborationDataManager
|
||||
.getInstance().getSessionManager();
|
||||
ISession session = sessionManager.getPeerToPeerSession();
|
||||
// TODO this doesn't seem right to use the session's
|
||||
// sessionId
|
||||
PlatformUI
|
||||
.getWorkbench()
|
||||
.getActiveWorkbenchWindow()
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
package com.raytheon.uf.viz.collaboration.comm.identity;
|
||||
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.event.IEventPublisher;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID;
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
|
@ -56,7 +57,7 @@ public interface IPeerToPeer extends ISession, IEventPublisher {
|
|||
* @param message
|
||||
* The message to send.
|
||||
*/
|
||||
void sendPeerToPeer(String to, String message)
|
||||
void sendPeerToPeer(IQualifiedID to, String message)
|
||||
throws CollaborationException;
|
||||
|
||||
}
|
||||
|
|
|
@ -34,6 +34,8 @@ import com.raytheon.uf.viz.collaboration.comm.identity.CollaborationException;
|
|||
import com.raytheon.uf.viz.collaboration.comm.identity.IMessage;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.IPeerToPeer;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.IPropertied.Property;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID;
|
||||
import com.raytheon.uf.viz.collaboration.comm.provider.TextMessage;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -111,15 +113,10 @@ public class PeerToPeerChat extends BaseSession implements IPeerToPeer {
|
|||
* @throws CollaborationException
|
||||
*/
|
||||
@Override
|
||||
public void sendPeerToPeer(String to, String message)
|
||||
public void sendPeerToPeer(IQualifiedID to, String message)
|
||||
throws CollaborationException {
|
||||
ID toID = createID(to);
|
||||
try {
|
||||
chatSender.sendChatMessage(toID, message);
|
||||
} catch (ECFException e) {
|
||||
throw new CollaborationException("Error sending message to peer "
|
||||
+ to, e);
|
||||
}
|
||||
TextMessage msg = new TextMessage(to, message);
|
||||
this.sendPeerToPeer(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -36,7 +36,7 @@ import com.raytheon.uf.viz.collaboration.comm.provider.event.ChatMessageEvent;
|
|||
import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
* Listens for peer to peer messages and routes them appropriately.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
|
|
|
@ -65,4 +65,9 @@ public class IDConverter {
|
|||
return rosterId;
|
||||
}
|
||||
|
||||
public static UserId convertFrom(String fqName) {
|
||||
return new UserId(Tools.parseName(fqName), Tools.parseHost(fqName),
|
||||
Tools.parseResource(fqName));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue