From efff6a8028636fc7b651bb5ad79823edb3d72429 Mon Sep 17 00:00:00 2001 From: James Korman Date: Tue, 27 Mar 2012 16:31:26 -0500 Subject: [PATCH] Issue #232 - Added addition peer-to-peer events Former-commit-id: 9791cc693a690e2d02d7e989fe06547546198ed2 [formerly fc99959e3ce36104d67596f0ddf37b5292bde5ef] [formerly e8b23e3687bc513f2852051e27a0be64d3fbc690] [formerly 9791cc693a690e2d02d7e989fe06547546198ed2 [formerly fc99959e3ce36104d67596f0ddf37b5292bde5ef] [formerly e8b23e3687bc513f2852051e27a0be64d3fbc690] [formerly ae6eddcd68978ceaf5b54bd4e5939abe2c508571 [formerly e8b23e3687bc513f2852051e27a0be64d3fbc690 [formerly 34994534b7e9b80b96e5ca038afef1977ba02383]]]] Former-commit-id: ae6eddcd68978ceaf5b54bd4e5939abe2c508571 Former-commit-id: f834bf7ca29c6284e148379f29c9bfe73a296717 [formerly 356892acd6ded2ee5d79a4d00c8e369bed5593d5] [formerly 653449fc2f2973859a684acad815bda3e8ddda5c [formerly 0ff25a52584d7181f520408ac4b61f5fee7b2530]] Former-commit-id: ed85fcbd5271b86e762bd07906ba4a6ba486f8a5 [formerly 64be5deba5fa63c95b3950da3f133d1a71b32115] Former-commit-id: 979397b7be3d7da03ae6a1ced83158b43d216d5f --- .../META-INF/MANIFEST.MF | 3 +- .../comm/identity/IPeerToPeer.java | 29 +- .../comm/identity/IPresence.java | 11 + .../comm/identity/ISharedDisplaySession.java | 22 +- .../identity/event/ITextMessageEvent.java | 49 +++ .../collaboration/comm/provider/Presence.java | 47 ++- .../comm/provider/event/ChatMessageEvent.java | 63 ++++ .../provider/event/VenueInvitationEvent.java | 101 +++++++ .../comm/provider/session/AccountManager.java | 11 +- .../comm/provider/session/BaseSession.java | 11 +- .../comm/provider/session/DataHandler.java | 55 ++++ .../comm/provider/session/DisplayEvent.java | 72 +++++ .../comm/provider/session/InitData.java | 72 +++++ .../comm/provider/session/PeerToPeerChat.java | 180 ++++-------- .../comm/provider/session/SessionManager.java | 51 +++- .../comm/provider/session/VenueSession.java | 278 ++++++++++++------ .../comm/provider/user/VenueParticipant.java | 9 +- .../comm/provider/user/VenueUserId.java | 8 - 18 files changed, 789 insertions(+), 283 deletions(-) create mode 100644 cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/identity/event/ITextMessageEvent.java create mode 100644 cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/event/ChatMessageEvent.java create mode 100644 cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/event/VenueInvitationEvent.java create mode 100644 cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/DataHandler.java create mode 100644 cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/DisplayEvent.java create mode 100644 cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/InitData.java diff --git a/cave/com.raytheon.uf.viz.collaboration/META-INF/MANIFEST.MF b/cave/com.raytheon.uf.viz.collaboration/META-INF/MANIFEST.MF index 71c04e56c7..63f11198d9 100644 --- a/cave/com.raytheon.uf.viz.collaboration/META-INF/MANIFEST.MF +++ b/cave/com.raytheon.uf.viz.collaboration/META-INF/MANIFEST.MF @@ -12,7 +12,8 @@ Require-Bundle: org.eclipse.core.runtime, org.eclipse.ecf.provider.xmpp;bundle-version="3.2.0", com.google.guava;bundle-version="1.0.0", com.raytheon.uf.common.serialization;bundle-version="1.12.1174", - com.raytheon.uf.viz.core;bundle-version="1.12.1174" + com.raytheon.uf.viz.core;bundle-version="1.12.1174", + org.jivesoftware.smack;bundle-version="3.1.100" Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-ActivationPolicy: lazy Export-Package: com.raytheon.uf.viz.collaboration, diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/identity/IPeerToPeer.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/identity/IPeerToPeer.java index 3eec08d198..e3484ff8de 100644 --- a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/identity/IPeerToPeer.java +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/identity/IPeerToPeer.java @@ -19,10 +19,7 @@ **/ package com.raytheon.uf.viz.collaboration.comm.identity; -import java.util.Collection; - -import com.raytheon.uf.viz.collaboration.comm.identity.listener.IMessageFilter; -import com.raytheon.uf.viz.collaboration.comm.identity.listener.IMessageListener; +import com.raytheon.uf.viz.collaboration.comm.identity.event.IEventPublisher; /** * TODO Add Description @@ -41,7 +38,7 @@ import com.raytheon.uf.viz.collaboration.comm.identity.listener.IMessageListener * @version 1.0 */ -public interface IPeerToPeer extends ISession { +public interface IPeerToPeer extends ISession, IEventPublisher { /** * Send a Text message. Note that the recipient of the message is @@ -57,26 +54,4 @@ public interface IPeerToPeer extends ISession { */ int sendPeerToPeer(String to, String message); - /** - * Add a listener for incoming messages. These messages will be filtered using - * the supplied message filter. - * @param listener A listener for incoming messages. - * @param filter A filter that either accepts/rejects messages. - * @return The listener that was added. - */ - IMessageListener addMessageListener(IMessageListener listener, IMessageFilter filter); - - /** - * Get the message listeners defined for the session. - * @return A not null collection of message listeners defined for the session. - */ - Collection getMessageListeners(); - - /** - * Remove a message listener from the session. - * @param listener A listener to remove. - * @return The listener that was removed. If the listener was not - * found, a null reference is returned. - */ - IMessageListener removeMessageListener(IMessageListener listener); } diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/identity/IPresence.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/identity/IPresence.java index 0e8619f450..aed5be759a 100644 --- a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/identity/IPresence.java +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/identity/IPresence.java @@ -102,5 +102,16 @@ public interface IPresence extends IPropertied { */ void setType(Type type); + /** + * Get the status message for this presence. + * @return The status message. + */ + String getStatusMessage(); + + /** + * Set the status message for this presence. + * @param statusMessage The status message. + */ + void setStatusMessage(String statusMessage); } diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/identity/ISharedDisplaySession.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/identity/ISharedDisplaySession.java index 758ed9ffa4..806ffa648f 100644 --- a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/identity/ISharedDisplaySession.java +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/identity/ISharedDisplaySession.java @@ -31,7 +31,7 @@ import com.raytheon.uf.viz.collaboration.comm.identity.user.ParticipantRole; * * * @@ -72,12 +76,28 @@ public interface ISharedDisplaySession extends IEventPublisher { void sendInitData(IChatID participant, IInitData initData) throws CollaborationException; + /** + * + * @param subscriber + */ + void subscribeToInitData(Object subscriber) throws CollaborationException; + + /** + * + * @param subscriber + * @throws CollaborationException + */ + void unSubscribeToInitData(Object subscriber) throws CollaborationException; + /** * * @param event */ void sendEvent(IDisplayEvent event) throws CollaborationException; + void sendEvent(IChatID participant, IDisplayEvent event) + throws CollaborationException; + /** * */ diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/identity/event/ITextMessageEvent.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/identity/event/ITextMessageEvent.java new file mode 100644 index 0000000000..ec34f05d93 --- /dev/null +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/identity/event/ITextMessageEvent.java @@ -0,0 +1,49 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.uf.viz.collaboration.comm.identity.event; + +import com.raytheon.uf.viz.collaboration.comm.provider.TextMessage; + +/** + * TODO Add Description + * + *
+ *
+ * SOFTWARE HISTORY
+ *
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Mar 27, 2012            jkorman     Initial creation
+ *
+ * 
+ * + * @author jkorman + * @version 1.0 + */ + +public interface ITextMessageEvent { + + /** + * + * @return + * + */ + TextMessage getMessage(); +} diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/Presence.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/Presence.java index 281267075f..4cff4a9138 100644 --- a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/Presence.java +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/Presence.java @@ -72,6 +72,8 @@ public class Presence implements IPresence { private Type type; + private String statusMessage; + /** * */ @@ -112,6 +114,23 @@ public class Presence implements IPresence { this.type = type; } + /** + * Get the status message for this presence. + * @return The status message. + */ + public String getStatusMessage() { + return statusMessage; + } + + /** + * Set the status message for this presence. + * @param statusMessage The status message. + */ + public void setStatusMessage(String statusMessage) { + this.statusMessage = statusMessage; + } + + private void ensureProperties() { if(properties == null) { properties = new HashMap(); @@ -150,21 +169,26 @@ public class Presence implements IPresence { return properties.values(); } + /** - * - * @param presence + * Convert from an ECF presence to this presence. + * @param presence The ECF presnce to convert from. * @return */ public static IPresence convertPresence(org.eclipse.ecf.presence.IPresence presence) { IPresence newPresence = null; if(presence != null) { newPresence = new Presence(); - - newPresence.setType(TYPE_MAP.get(presence.getType())); newPresence.setMode(MODE_MAP.get(presence.getMode())); - - System.out.println(presence.getStatus()); + newPresence.setStatusMessage(presence.getStatus()); + @SuppressWarnings("unchecked") + Map properties = (Map) presence.getProperties(); + if(properties != null) { + for(String key : properties.keySet()) { + newPresence.setProperty(key, properties.get(key)); + } + } } return newPresence; } @@ -178,6 +202,17 @@ public class Presence implements IPresence { public static org.eclipse.ecf.presence.IPresence convertPresence(IPresence presence) { org.eclipse.ecf.presence.IPresence newPresence = null; if(presence != null) { + newPresence = new org.eclipse.ecf.presence.Presence(); + +// Map properties = presence.getProperties(); +// if(properties != null) { +// for(String key : properties.keySet()) { +// newPresence.setProperty(key, properties.get(key)); +// } +// } + + + } diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/event/ChatMessageEvent.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/event/ChatMessageEvent.java new file mode 100644 index 0000000000..13416d0057 --- /dev/null +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/event/ChatMessageEvent.java @@ -0,0 +1,63 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.uf.viz.collaboration.comm.provider.event; + +import com.raytheon.uf.viz.collaboration.comm.identity.event.ITextMessageEvent; +import com.raytheon.uf.viz.collaboration.comm.provider.TextMessage; + +/** + * TODO Add Description + * + *
+ *
+ * SOFTWARE HISTORY
+ *
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Mar 27, 2012            jkorman     Initial creation
+ *
+ * 
+ * + * @author jkorman + * @version 1.0 + */ + +public class ChatMessageEvent implements ITextMessageEvent { + + private final TextMessage message; + + /** + * + * @param msg + */ + public ChatMessageEvent(TextMessage msg) { + message = msg; + } + + + /** + * + * @return + * + */ + public TextMessage getMessage() { + return message; + } +} diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/event/VenueInvitationEvent.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/event/VenueInvitationEvent.java new file mode 100644 index 0000000000..05b6699d47 --- /dev/null +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/event/VenueInvitationEvent.java @@ -0,0 +1,101 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.uf.viz.collaboration.comm.provider.event; + +import com.raytheon.uf.viz.collaboration.comm.identity.event.IVenueInvitationEvent; +import com.raytheon.uf.viz.collaboration.comm.identity.user.IChatID; +import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID; + +/** + * TODO Add Description + * + *
+ *
+ * SOFTWARE HISTORY
+ *
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Mar 27, 2012            jkorman     Initial creation
+ *
+ * 
+ * + * @author jkorman + * @version 1.0 + */ + +public class VenueInvitationEvent implements IVenueInvitationEvent { + + private IQualifiedID venueId; + + private IChatID invitor; + + private String subject; + + private String body; + + /** + * + * @param roomId + * @param invitor + * @param subject + * @param body + */ + public VenueInvitationEvent(IQualifiedID venueId, IChatID invitor, String subject, String body) { + this.venueId = venueId; + this.invitor = invitor; + this.subject = subject; + this.body = body; + } + + + /** + * Get the room identifier + * @see com.raytheon.uf.viz.collaboration.comm.identity.event.IVenueInvitationEvent#getRoomId() + */ + @Override + public IQualifiedID getRoomId() { + return venueId; + } + + /** + * @see com.raytheon.uf.viz.collaboration.comm.identity.event.IVenueInvitationEvent#getInvitor() + */ + @Override + public IChatID getInvitor() { + return invitor; + } + + /** + * @see com.raytheon.uf.viz.collaboration.comm.identity.event.IVenueInvitationEvent#getSubject() + */ + @Override + public String getSubject() { + return subject; + } + + /** + * @see com.raytheon.uf.viz.collaboration.comm.identity.event.IVenueInvitationEvent#getBody() + */ + @Override + public String getBody() { + return body; + } + +} diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/AccountManager.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/AccountManager.java index d90be62acc..330b2824ab 100644 --- a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/AccountManager.java +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/AccountManager.java @@ -105,6 +105,7 @@ public class AccountManager implements IAccountManager { */ AccountManager(IPresenceContainerAdapter adapter) { presenceAdapter = adapter; + presenceAdapter.getRosterManager().addRosterSubscriptionListener(autoResponder); } /** @@ -122,6 +123,8 @@ public class AccountManager implements IAccountManager { } /** + * + * * @see com.raytheon.uf.viz.collaboration.comm.identity.IAccountManager#getAutoSubscriptionMode() */ @Override @@ -148,6 +151,8 @@ public class AccountManager implements IAccountManager { /** * + * @param password The new password. For security the password is a character array that will + * be zero'd after use. * @see com.raytheon.uf.viz.collaboration.comm.identity.IAccountManager#changePassword(char[]) */ @Override @@ -181,8 +186,8 @@ public class AccountManager implements IAccountManager { } /** - * - * + * Determines if the server allows new accounts to be created by the user. + * @throws CollaborationException * @see com.raytheon.uf.viz.collaboration.comm.identity.IAccountManager#canCreateAccount() */ @Override @@ -193,7 +198,7 @@ public class AccountManager implements IAccountManager { try { canCreate = manager.isAccountCreationSupported(); } catch (ECFException e) { - throw new CollaborationException("Could not delete account"); + throw new CollaborationException("Error attempting to determine if accounts may be created."); } } return canCreate; diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/BaseSession.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/BaseSession.java index bfff18415b..4060c8a9af 100644 --- a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/BaseSession.java +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/BaseSession.java @@ -174,9 +174,9 @@ public abstract class BaseSession implements ISession, IEventPublisher { public void close() { // Unregister any handlers added using this session - for(Object o : eventSubscribers.values()) { - managerEventBus.unregister(o); - } +// for(Object o : eventSubscribers.values()) { +// managerEventBus.unregister(o); +// } sessionManager.removeSession(this); } @@ -201,6 +201,7 @@ public abstract class BaseSession implements ISession, IEventPublisher { public void registerEventHandler(Object handler) { if(!eventSubscribers.containsKey(handler)) { eventBus.register(handler); + eventSubscribers.put(handler, handler); } } @@ -223,6 +224,10 @@ public abstract class BaseSession implements ISession, IEventPublisher { return eventBus; } + EventBus getManagerEventPublisher() { + return managerEventBus; + } + /** * * @param name diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/DataHandler.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/DataHandler.java new file mode 100644 index 0000000000..7060afe34e --- /dev/null +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/DataHandler.java @@ -0,0 +1,55 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.uf.viz.collaboration.comm.provider.session; + +import com.google.common.eventbus.Subscribe; +import com.raytheon.uf.viz.collaboration.comm.identity.event.IDisplayEvent; +import com.raytheon.uf.viz.collaboration.comm.identity.event.IInitData; + +/** + * TODO Add Description + * + *
+ *
+ * SOFTWARE HISTORY
+ *
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Mar 27, 2012            jkorman     Initial creation
+ *
+ * 
+ * + * @author jkorman + * @version 1.0 + */ + +public class DataHandler { + + @Subscribe + public void handle(IInitData initdata) { + System.out.println("Handling IInitData " + initdata); + } + + @Subscribe + public void handle(IDisplayEvent event) { + System.out.println("Handling IDisplayEvent " + event); + } + +} diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/DisplayEvent.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/DisplayEvent.java new file mode 100644 index 0000000000..8102add334 --- /dev/null +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/DisplayEvent.java @@ -0,0 +1,72 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.uf.viz.collaboration.comm.provider.session; + +import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; +import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; +import com.raytheon.uf.viz.collaboration.comm.identity.event.IDisplayEvent; + +/** + * TODO Add Description + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Mar 27, 2012            jkorman     Initial creation
+ * 
+ * 
+ * + * @author jkorman + * @version 1.0 + */ +@DynamicSerialize +public class DisplayEvent implements IDisplayEvent { + + @DynamicSerializeElement + private String name; + + public DisplayEvent() { + + } + + /** + * @return the name + */ + public String getName() { + return name; + } + + /** + * @param name + * the name to set + */ + public void setName(String name) { + this.name = name; + } + + @Override + public String toString() { + return name; + } + +} diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/InitData.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/InitData.java new file mode 100644 index 0000000000..d6eb16de3f --- /dev/null +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/InitData.java @@ -0,0 +1,72 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.uf.viz.collaboration.comm.provider.session; + +import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; +import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; +import com.raytheon.uf.viz.collaboration.comm.identity.event.IDisplayEvent; +import com.raytheon.uf.viz.collaboration.comm.identity.event.IInitData; + +/** + * TODO Add Description + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Mar 27, 2012            jkorman     Initial creation
+ * 
+ * 
+ * + * @author jkorman + * @version 1.0 + */ +@DynamicSerialize +public class InitData implements IInitData { + + @DynamicSerializeElement + private String name; + + public InitData() { + + } + + /** + * @return the name + */ + public String getName() { + return name; + } + + /** + * @param name + * the name to set + */ + public void setName(String name) { + this.name = name; + } + + @Override + public String toString() { + return name; + } +} diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/PeerToPeerChat.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/PeerToPeerChat.java index 0cd2fb96c3..296a7e6493 100644 --- a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/PeerToPeerChat.java +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/PeerToPeerChat.java @@ -19,29 +19,29 @@ **/ package com.raytheon.uf.viz.collaboration.comm.provider.session; -import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; -import java.util.List; import java.util.Map; import org.eclipse.ecf.core.IContainer; import org.eclipse.ecf.core.identity.ID; -import org.eclipse.ecf.core.identity.Namespace; import org.eclipse.ecf.core.util.ECFException; +import org.eclipse.ecf.presence.IIMMessageEvent; +import org.eclipse.ecf.presence.IIMMessageListener; import org.eclipse.ecf.presence.im.IChatMessage; +import org.eclipse.ecf.presence.im.IChatMessageEvent; import org.eclipse.ecf.presence.im.IChatMessageSender; import com.google.common.eventbus.EventBus; +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.IPresence; import com.raytheon.uf.viz.collaboration.comm.identity.IPropertied.Property; -import com.raytheon.uf.viz.collaboration.comm.identity.event.IEventPublisher; -import com.raytheon.uf.viz.collaboration.comm.identity.listener.IMessageFilter; -import com.raytheon.uf.viz.collaboration.comm.identity.listener.IMessageListener; -import com.raytheon.uf.viz.collaboration.comm.identity.listener.IPresenceListener; +import com.raytheon.uf.viz.collaboration.comm.identity.event.ITextMessageEvent; import com.raytheon.uf.viz.collaboration.comm.provider.Errors; +import com.raytheon.uf.viz.collaboration.comm.provider.TextMessage; +import com.raytheon.uf.viz.collaboration.comm.provider.Tools; +import com.raytheon.uf.viz.collaboration.comm.provider.event.ChatMessageEvent; /** * @@ -62,85 +62,7 @@ import com.raytheon.uf.viz.collaboration.comm.provider.Errors; * @version 1.0 */ -public class PeerToPeerChat extends BaseSession implements IPeerToPeer, - IEventPublisher { - - /** - * - * TODO Add Description - * - *
-     * 
-     * SOFTWARE HISTORY
-     * 
-     * Date         Ticket#    Engineer    Description
-     * ------------ ---------- ----------- --------------------------
-     * Feb 27, 2012            jkorman     Initial creation
-     * 
-     * 
- * - * @author jkorman - * @version 1.0 - */ - private static class InternalListener { - - private IMessageListener messageListener; - - private IPresenceListener presenceListener; - - private IMessageFilter filter; - - /** - * - * @param listener - * @param filter - */ - public InternalListener(IMessageListener listener, IMessageFilter filter) { - messageListener = listener; - this.filter = filter; - - } - - /** - * - * @param listener - * @param filter - */ - public InternalListener(IPresenceListener listener, - IMessageFilter filter) { - presenceListener = listener; - this.filter = filter; - } - - /** - * - * @param message - */ - public void processMessage(IMessage message) { - messageListener.processMessage(message); - } - - /** - * - * @param presence - */ - public void processPresence(IPresence presence) { - presenceListener.notifyPresence(presence); - } - - /** - * - * @param message - * @return - */ - public boolean filter(IMessage message) { - return filter.filter(message); - } - } - - private List messageListeners = null; - - private Namespace namespace = null; +public class PeerToPeerChat extends BaseSession implements IPeerToPeer { private IChatMessageSender chatSender = null; @@ -153,15 +75,9 @@ public class PeerToPeerChat extends BaseSession implements IPeerToPeer, PeerToPeerChat(IContainer container, EventBus externalBus, SessionManager manager) { super(container, externalBus, manager); - try { - setup(); - } catch (ECFException e) { - // TODO - e.printStackTrace(); - } + setup(); chatSender = getConnectionPresenceAdapter().getChatManager() .getChatMessageSender(); - } /** @@ -217,42 +133,48 @@ public class PeerToPeerChat extends BaseSession implements IPeerToPeer, return status; } - /** - * - */ - @Override - public IMessageListener addMessageListener(IMessageListener listener, - IMessageFilter filter) { - InternalListener messageListener = new InternalListener(listener, - filter); - messageListeners.add(messageListener); - return listener; - } + void setup() { + try { + super.setup(); - /** - * - */ - @Override - public Collection getMessageListeners() { - Collection listeners = new ArrayList(); - synchronized (messageListeners) { - for (InternalListener intListener : messageListeners) { - listeners.add(intListener.messageListener); - } + getConnectionPresenceAdapter().getChatManager().addMessageListener( + new IIMMessageListener() { + + @Override + public void handleMessageEvent( + IIMMessageEvent messageEvent) { + if (messageEvent instanceof IChatMessageEvent) { + IChatMessageEvent event = (IChatMessageEvent) messageEvent; + + IChatMessage msg = event.getChatMessage(); + String body = msg.getBody(); + if (body != null) { + if (body.startsWith("[[COMMAND#")) { + Object object = null; + try { + object = Tools.unMarshallData(body); + } catch (CollaborationException e) { + System.out + .println("Error unmarshalling PeerToPeer data"); + } + if (object != null) { + getEventPublisher().post(object); + } + } else { + // anything else pass to the normal text + TextMessage textMsg = null; + + ITextMessageEvent chatEvent = new ChatMessageEvent( + textMsg); + + getEventPublisher().post(chatEvent); + } + } + } + } + }); + } catch (ECFException ecfe) { + System.out.println("Error setting up PeerToPeer chat listeners"); } - return listeners; } - - /** - * - */ - @Override - public IMessageListener removeMessageListener(IMessageListener listener) { - IMessageListener removed = null; - if (messageListeners.remove(listener)) { - removed = listener; - } - return removed; - } - } diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/SessionManager.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/SessionManager.java index bccc129557..e269061ea7 100644 --- a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/SessionManager.java +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/SessionManager.java @@ -41,6 +41,7 @@ import org.eclipse.ecf.presence.chatroom.IChatRoomInfo; import org.eclipse.ecf.presence.chatroom.IChatRoomInvitationListener; import org.eclipse.ecf.presence.chatroom.IChatRoomManager; import org.eclipse.ecf.presence.roster.IRoster; +import org.jivesoftware.smack.XMPPConnection; import com.google.common.eventbus.EventBus; import com.raytheon.uf.viz.collaboration.comm.identity.CollaborationException; @@ -49,11 +50,13 @@ import com.raytheon.uf.viz.collaboration.comm.identity.IPresence; import com.raytheon.uf.viz.collaboration.comm.identity.ISession; import com.raytheon.uf.viz.collaboration.comm.identity.ISharedDisplaySession; import com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession; +import com.raytheon.uf.viz.collaboration.comm.identity.event.IVenueInvitationEvent; import com.raytheon.uf.viz.collaboration.comm.identity.info.IVenueInfo; import com.raytheon.uf.viz.collaboration.comm.identity.listener.IVenueInvitationListener; import com.raytheon.uf.viz.collaboration.comm.identity.roster.IRosterManager; import com.raytheon.uf.viz.collaboration.comm.provider.Presence; import com.raytheon.uf.viz.collaboration.comm.provider.Tools; +import com.raytheon.uf.viz.collaboration.comm.provider.event.VenueInvitationEvent; import com.raytheon.uf.viz.collaboration.comm.provider.info.InfoAdapter; import com.raytheon.uf.viz.collaboration.comm.provider.roster.RosterManager; @@ -115,6 +118,8 @@ public class SessionManager { * */ public SessionManager(String account, String password) throws Exception { + // XMPPConnection.DEBUG_ENABLED = true; + try { container = ContainerFactory.getDefault().createContainer(PROVIDER); } catch (ContainerCreateException cce) { @@ -128,6 +133,8 @@ public class SessionManager { } catch (Exception e) { } + setupAccountManager(); + eventBus = new EventBus(); sessions = new HashMap(); @@ -136,6 +143,21 @@ public class SessionManager { setupInternalVenueInvitationListener(); } + /** + * + * @param account The account name to connect to. + * @param password The password to use for connection. + * @param initialPresence The initial presence for the account name. + * @throws ContainerCreateException + * + */ + public SessionManager(String account, String password, IPresence initialPresence) throws Exception { + this(account, password); + if(accountManager != null) { + accountManager.sendPresence(initialPresence); + } + } + /** * */ @@ -161,11 +183,11 @@ public class SessionManager { private void setupAccountManager() { if (accountManager == null) { if (isConnected()) { - IPresenceContainerAdapter presence = Tools + IPresenceContainerAdapter presenceAdapter = Tools .getPresenceContainerAdapter(container, IPresenceContainerAdapter.class); - if (presence != null) { - accountManager = new AccountManager(presence); + if (presenceAdapter != null) { + accountManager = new AccountManager(presenceAdapter); } } } @@ -188,10 +210,10 @@ public class SessionManager { */ private void setupRosterManager() { IRoster roster = null; - IPresenceContainerAdapter presence = Tools.getPresenceContainerAdapter( + IPresenceContainerAdapter presenceAdapter = Tools.getPresenceContainerAdapter( container, IPresenceContainerAdapter.class); - if (presence != null) { - roster = presence.getRosterManager().getRoster(); + if (presenceAdapter != null) { + roster = presenceAdapter.getRosterManager().getRoster(); if (roster != null) { rosterManager = new RosterManager(roster); } @@ -353,10 +375,10 @@ public class SessionManager { // Check to see if the container has been connected. Collection info = new ArrayList(); if (isConnected()) { - IPresenceContainerAdapter presence = Tools + IPresenceContainerAdapter presenceAdapter = Tools .getPresenceContainerAdapter(container, IPresenceContainerAdapter.class); - IChatRoomManager venueManager = presence.getChatRoomManager(); + IChatRoomManager venueManager = presenceAdapter.getChatRoomManager(); if (venueManager != null) { IChatRoomInfo[] roomInfo = venueManager.getChatRoomInfos(); for (IChatRoomInfo rInfo : roomInfo) { @@ -401,11 +423,11 @@ public class SessionManager { */ private void setupInternalVenueInvitationListener() { if (isConnected()) { - IPresenceContainerAdapter presence = Tools + IPresenceContainerAdapter presenceAdapter = Tools .getPresenceContainerAdapter(container, IPresenceContainerAdapter.class); - if (presence != null) { - IChatRoomManager venueManager = presence.getChatRoomManager(); + if (presenceAdapter != null) { + IChatRoomManager venueManager = presenceAdapter.getChatRoomManager(); if (venueManager != null) { intInvitationListener = new IChatRoomInvitationListener() { @Override @@ -415,6 +437,13 @@ public class SessionManager { invitationListener.handleInvitation(null, null, subject, body); } + + +// IVenueInvitationEvent invite = new VenueInvitationEvent(roomID, from, subject, body); + + + + } }; venueManager.addInvitationListener(intInvitationListener); diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/VenueSession.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/VenueSession.java index 510e29982b..0982d74b37 100644 --- a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/VenueSession.java +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/VenueSession.java @@ -44,6 +44,7 @@ import org.eclipse.ecf.presence.chatroom.IChatRoomParticipantListener; import org.eclipse.ecf.provider.xmpp.identity.XMPPRoomID; import com.google.common.eventbus.EventBus; +import com.google.common.eventbus.Subscribe; 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.IPresence; @@ -209,6 +210,8 @@ public class VenueSession extends BaseSession implements IVenueSession, private EnumSet roles = EnumSet .noneOf(ParticipantRole.class); + private Map initSubscribers = new HashMap(); + /** * * @param container @@ -224,48 +227,66 @@ public class VenueSession extends BaseSession implements IVenueSession, } finally { initListeners(); } - // Runnable r = new Runnable() { - // @Override - // public void run() { - // try { - // Thread.sleep(20000); - // - // TestJAXBObject j = new TestJAXBObject(); - // j.setItem_1("This is an object"); - // j.setValue(5); - // sendRenderableObject(j); - // } catch (Exception e) { - // System.out.println("Error sending RenderableObject"); - // } - // } - // }; - // Thread t = new Thread(r); - // t.start(); - // registerEventHandler(this); + +// Runnable r = new Runnable() { +// @Override +// public void run() { +// try { +// Thread.sleep(20000); +// +// TestJAXBObject j = new TestJAXBObject(); +// j.setItem_1("This is an object"); +// j.setValue(5); +// sendRenderableObject(j); +// +// VenueParticipant id = new VenueParticipant("jkorman", "paul", "awipscm.omaha.us.ray.com"); +// id.setResource("cave"); +// IInitData d = new InitData(); +// ((InitData) d).setName("This is a test init data object"); +// +// IDisplayEvent e = new DisplayEvent(); +// ((DisplayEvent) e).setName("This is a test display event"); +// +// sendInitData(id, d); +// sendEvent(id,e); +// } catch (Exception e) { +// System.out.println("Error sending RenderableObject"); +// } +// } +// }; +// Thread t = new Thread(r); +// t.start(); +// registerEventHandler(this); +// try { +// DataHandler h = new DataHandler(); +// subscribeToInitData(h); +// } catch (CollaborationException ce) { +// ce.printStackTrace(); +// } } - // @Subscribe - // public void handle(IRenderable renderable) { - // System.out.println("Renderable found"); - // if(renderable instanceof TestJAXBObject) { - // TestJAXBObject j = (TestJAXBObject) renderable; - // if(j.getValue() < 100) { - // System.out.println(String.format("%s %d Renderable", j.getItem_1(), - // j.getValue())); - // j.setValue(j.getValue() + 200); - // j.setItem_1("Now for the return trip"); - // try { - // sendRenderableObject(j); - // } catch (CollaborationException ce) { - // System.out.println("Error sending RenderableObject"); - // } - // } else { - // System.out.println(String.format("%s %d Renderable", j.getItem_1(), - // j.getValue())); - // } - // } - // } - +// @Subscribe +// public void handle(IRenderable renderable) { +// System.out.println("Renderable found"); +// if (renderable instanceof TestJAXBObject) { +// TestJAXBObject j = (TestJAXBObject) renderable; +// if (j.getValue() < 100) { +// System.out.println(String.format("%s %d Renderable", +// j.getItem_1(), j.getValue())); +// j.setValue(j.getValue() + 200); +// j.setItem_1("Now for the return trip"); +// try { +// sendRenderableObject(j); +// } catch (CollaborationException ce) { +// System.out.println("Error sending RenderableObject"); +// } +// } else { +// System.out.println(String.format("%s %d Renderable", +// j.getItem_1(), j.getValue())); +// } +// } +// } + /** * * @throws ECFException @@ -402,6 +423,76 @@ public class VenueSession extends BaseSession implements IVenueSession, if (venueInfo != null) { try { venueContainer = venueInfo.createChatRoomContainer(); + + IChatRoomParticipantListener pListener = new IChatRoomParticipantListener() { + @Override + public void handleArrived(IUser participant) { + // IVenueParticipant p = new VenueParticipant( + // participant.getName(), + // participant.getNickname()); + // + // System.out.println("Arrived"); + // IVenueParticipantEvent event = new + // VenueParticipantEvent( + // p, ParticipantEventType.ARRIVED); + // + // getEventPublisher().post(event); + } + + @Override + public void handleUpdated(IUser participant) { + // IVenueParticipant p = new VenueParticipant( + // participant.getName(), + // participant.getNickname()); + // + // System.out.println("Updated"); + // IVenueParticipantEvent event = new + // VenueParticipantEvent( + // p, ParticipantEventType.UPDATED); + // getEventPublisher().post(event); + } + + @Override + public void handleDeparted(IUser participant) { + // IVenueParticipant p = new VenueParticipant( + // participant.getName(), + // participant.getNickname()); + // + // System.out.println("Departed"); + // IVenueParticipantEvent event = new + // VenueParticipantEvent( + // p, ParticipantEventType.DEPARTED); + // getEventPublisher().post(event); + } + + @Override + public void handlePresenceUpdated(ID fromID, + org.eclipse.ecf.presence.IPresence presence) { + + IVenueParticipant vp = new VenueParticipant(); + String fullName = fromID.getName(); + vp.setName(Tools.parseName(fullName)); + vp.setHost(Tools.parseHost(fullName)); + vp.setResource(Tools.parseResource(fullName)); + IPresence p = Presence.convertPresence(presence); + IVenueParticipantEvent event = null; + if (IPresence.Type.AVAILABLE.equals(p.getType())) { + event = new VenueParticipantEvent(vp, p, + ParticipantEventType.ARRIVED); + getEventPublisher().post(event); + } else if (IPresence.Type.UNAVAILABLE.equals(p + .getType())) { + event = new VenueParticipantEvent(vp, p, + ParticipantEventType.DEPARTED); + getEventPublisher().post(event); + } + event = new VenueParticipantEvent(vp, p, + ParticipantEventType.PRESENCE_UPDATED); + getEventPublisher().post(event); + } + }; + venueContainer.addChatRoomParticipantListener(pListener); + venueContainer.connect(venueInfo.getRoomID(), null); if (venueContainer.getConnectedID() != null) { @@ -418,58 +509,6 @@ public class VenueSession extends BaseSession implements IVenueSession, }; venueContainer.addMessageListener(intListener); - IChatRoomParticipantListener pListener = new IChatRoomParticipantListener() { - @Override - public void handleArrived(IUser participant) { - IVenueParticipant p = new VenueParticipant( - participant.getName(), - participant.getNickname()); - - IVenueParticipantEvent event = new VenueParticipantEvent( - p, ParticipantEventType.ARRIVED); - - getEventPublisher().post(event); - } - - @Override - public void handleUpdated(IUser participant) { - IVenueParticipant p = new VenueParticipant( - participant.getName(), - participant.getNickname()); - - IVenueParticipantEvent event = new VenueParticipantEvent( - p, ParticipantEventType.UPDATED); - getEventPublisher().post(event); - } - - @Override - public void handleDeparted(IUser participant) { - IVenueParticipant p = new VenueParticipant( - participant.getName(), - participant.getNickname()); - - IVenueParticipantEvent event = new VenueParticipantEvent( - p, ParticipantEventType.DEPARTED); - getEventPublisher().post(event); - } - - @Override - public void handlePresenceUpdated(ID fromID, - org.eclipse.ecf.presence.IPresence presence) { - - fromID.getName(); - IVenueParticipant vp = new VenueParticipant(); - vp.setName(fromID.getName()); - - IPresence p = Presence.convertPresence(presence); - - IVenueParticipantEvent event = new VenueParticipantEvent( - vp, p, - ParticipantEventType.PRESENCE_UPDATED); - getEventPublisher().post(event); - } - }; - venueContainer.addChatRoomParticipantListener(pListener); } } catch (Exception e) { errorStatus = -1; @@ -631,7 +670,60 @@ public class VenueSession extends BaseSession implements IVenueSession, if (session != null) { String message = Tools.marshallData(initData); if (message != null) { - session.sendPeerToPeer(participant.getName(), message); + session.sendPeerToPeer(participant.getFQName(), message); + } + } + } + + /** + * Subscribe to peer to peer data events. + * + * @param An + * object that subscribes to peer to peer events. + */ + @Override + public void subscribeToInitData(Object subscriber) + throws CollaborationException { + if (!initSubscribers.containsKey(subscriber)) { + initSubscribers.put(subscriber, subscriber); + } + PeerToPeerChat session = getP2PSession(); + session.getEventPublisher().register(subscriber); + } + + /** + * UnSubscribe to peer to peer data events. + * + * @param An + * object that will be unsubscribed for peer to peer events. + */ + @Override + public void unSubscribeToInitData(Object subscriber) + throws CollaborationException { + if (initSubscribers.containsKey(subscriber)) { + initSubscribers.remove(subscriber); + PeerToPeerChat session = getP2PSession(); + session.getEventPublisher().unregister(subscriber); + } + } + + /** + * + * @param participant + * @param event + * @throws CollaborationException + */ + @Override + public void sendEvent( + com.raytheon.uf.viz.collaboration.comm.identity.user.IChatID participant, + IDisplayEvent event) throws CollaborationException { + + PeerToPeerChat session = null; + session = getP2PSession(); + if (session != null) { + String message = Tools.marshallData(event); + if (message != null) { + session.sendPeerToPeer(participant.getFQName(), message); } } } diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/user/VenueParticipant.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/user/VenueParticipant.java index 2b100b59cc..97309599d8 100644 --- a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/user/VenueParticipant.java +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/user/VenueParticipant.java @@ -175,7 +175,14 @@ public class VenueParticipant implements IVenueParticipant { */ @Override public String getFQName() { - return null; + StringBuilder sb = new StringBuilder(name); + sb.append("@"); + sb.append(host); + if(resource != null) { + sb.append("/"); + sb.append(resource); + } + return sb.toString(); } } diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/user/VenueUserId.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/user/VenueUserId.java index 2c05d24cd7..702999fb75 100644 --- a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/user/VenueUserId.java +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/user/VenueUserId.java @@ -121,12 +121,4 @@ public class VenueUserId extends UserId implements IChatID { String host = Tools.parseHost(user.getName()); return new VenueUserId(name, user.getNickname(), host); } - - - - - - - - }