Issue #232 - Added addition peer-to-peer events
Former-commit-id:e8b23e3687
[formerly 34994534b7e9b80b96e5ca038afef1977ba02383] Former-commit-id:ae6eddcd68
This commit is contained in:
parent
a692caba1c
commit
0ff25a5258
18 changed files with 789 additions and 283 deletions
|
@ -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,
|
||||
|
|
|
@ -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<IMessageListener> 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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ import com.raytheon.uf.viz.collaboration.comm.identity.user.ParticipantRole;
|
|||
*
|
||||
*
|
||||
* <ul>
|
||||
* <li>EventBus subscription events. Implementors are required to post the
|
||||
* <li>EventBus subscription events. Implementors may to post the
|
||||
* following events.</li>
|
||||
* <ul>
|
||||
* <li><strong>IVenueParticipantEvent</strong> : This event is posted when a
|
||||
|
@ -42,6 +42,10 @@ import com.raytheon.uf.viz.collaboration.comm.identity.user.ParticipantRole;
|
|||
* <li><strong>IDisplayEvent</strong> : These messages are CAVE to CAVE events</li>
|
||||
* <li><strong>IRenderable</strong> : These messages are CAVE to CAVE
|
||||
* display......</li>
|
||||
* <li><strong>IInitData</strong> : These messages are CAVE to CAVE
|
||||
* initialization data......</li>
|
||||
* <li><strong>IDisplayEvent</strong> : These messages are CAVE to CAVE
|
||||
* display......</li>
|
||||
*
|
||||
* </ul>
|
||||
* </ul>
|
||||
|
@ -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;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
|
|
@ -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
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Mar 27, 2012 jkorman Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author jkorman
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public interface ITextMessageEvent {
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*
|
||||
*/
|
||||
TextMessage getMessage();
|
||||
}
|
|
@ -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<String,Property>();
|
||||
|
@ -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<String, String> properties = (Map<String, String>) 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<String, String> properties = presence.getProperties();
|
||||
// if(properties != null) {
|
||||
// for(String key : properties.keySet()) {
|
||||
// newPresence.setProperty(key, properties.get(key));
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Mar 27, 2012 jkorman Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
}
|
|
@ -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
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Mar 27, 2012 jkorman Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Mar 27, 2012 jkorman Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @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);
|
||||
}
|
||||
|
||||
}
|
|
@ -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
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Mar 27, 2012 jkorman Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Mar 27, 2012 jkorman Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
}
|
|
@ -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
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Feb 27, 2012 jkorman Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @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<InternalListener> 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<IMessageListener> getMessageListeners() {
|
||||
Collection<IMessageListener> listeners = new ArrayList<IMessageListener>();
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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<String, ISession>();
|
||||
|
@ -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<IVenueInfo> info = new ArrayList<IVenueInfo>();
|
||||
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);
|
||||
|
|
|
@ -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<ParticipantRole> roles = EnumSet
|
||||
.noneOf(ParticipantRole.class);
|
||||
|
||||
private Map<Object, Object> initSubscribers = new HashMap<Object, Object>();
|
||||
|
||||
/**
|
||||
*
|
||||
* @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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -121,12 +121,4 @@ public class VenueUserId extends UserId implements IChatID {
|
|||
String host = Tools.parseHost(user.getName());
|
||||
return new VenueUserId(name, user.getNickname(), host);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue