Issue #437 - Corrected venue command message loopback

Former-commit-id: 23a2cd033a [formerly c3ba8bd9416f18358f2a976ee2104e4e614321c3]
Former-commit-id: e663a9e5dc
This commit is contained in:
James Korman 2012-04-04 13:41:25 -05:00
parent 28df06150e
commit 44b07395fb
4 changed files with 80 additions and 31 deletions

View file

@ -149,6 +149,40 @@ public abstract class BaseSession implements ISession {
return connectionPresence;
}
/**
*
* @return
*/
EventBus getManagerEventPublisher() {
return managerEventBus;
}
/**
*
* @return
*/
SessionManager getSessionManager() {
return sessionManager;
}
/**
*
* @param name
* @return
*/
public ID createID(String name) throws IDCreateException {
ID id = null;
name += "/foo"; // TODO fix this in a better way
if (connectionNamespace != null) {
id = IDFactory.getDefault().createID(connectionNamespace, name);
}
return id;
}
// *****************
// Implement IEventPublisher methods
// *****************
/**
* @see com.raytheon.uf.viz.collaboration.comm.identity.ISession#getUserID()
*/
@ -230,21 +264,4 @@ public abstract class BaseSession implements ISession {
return eventBus;
}
EventBus getManagerEventPublisher() {
return managerEventBus;
}
/**
*
* @param name
* @return
*/
public ID createID(String name) throws IDCreateException {
ID id = null;
name += "/foo"; // TODO fix this in a better way
if (connectionNamespace != null) {
id = IDFactory.getDefault().createID(connectionNamespace, name);
}
return id;
}
}

View file

@ -76,9 +76,6 @@ public class PeerToPeerCommHelper implements IIMMessageListener {
@Override
public void handleMessageEvent(IIMMessageEvent messageEvent) {
System.out.println("Handling event "
+ messageEvent.getClass().getName());
if (messageEvent instanceof IChatMessageEvent) {
IChatMessageEvent event = (IChatMessageEvent) messageEvent;
System.out.println(" message event.body "
@ -95,10 +92,6 @@ public class PeerToPeerCommHelper implements IIMMessageListener {
routeMessage(msg);
}
}
} else {
if(messageEvent != null) {
System.out.println(messageEvent.getClass().getName() + " trapped in PeerToPeerCommHelper");
}
}
}

View file

@ -217,6 +217,14 @@ public class SessionManager implements IEventPublisher {
}
}
/**
* Return the account string that was used to create this manager.
* @return The account string.
*/
public String getAccount() {
return account;
}
/**
* Get the account manager for this connection.
*
@ -353,8 +361,10 @@ public class SessionManager implements IEventPublisher {
if (session != null) {
session.createVenue(venueName, subject);
IChatID me = new VenueUserId("jkorman",
"awipscm.omaha.us.ray.com");
String name = Tools.parseName(account);
String host = Tools.parseHost(account);
IChatID me = new VenueUserId(name, host);
session.setSessionLeader(me);
session.setSessionDataProvider(me);

View file

@ -149,7 +149,6 @@ public class VenueSession extends BaseSession implements IVenueSession,
VenueSession(IContainer container, EventBus externalBus,
SessionManager manager) throws CollaborationException {
super(container, externalBus, manager);
}
/**
@ -352,10 +351,10 @@ public class VenueSession extends BaseSession implements IVenueSession,
if (session != null) {
String message = Tools.marshallData(initData);
if (message != null) {
TextMessage msg = new TextMessage(participant, message);
msg.setProperty(Tools.PROP_SESSION_ID, getSessionId());
session.sendPeerToPeer(msg);
}
}
@ -414,7 +413,7 @@ public class VenueSession extends BaseSession implements IVenueSession,
if (session != null) {
String message = Tools.marshallData(event);
if (message != null) {
TextMessage msg = new TextMessage(participant, message);
msg.setProperty(Tools.PROP_SESSION_ID, getSessionId());
session.sendPeerToPeer(msg);
@ -659,7 +658,9 @@ public class VenueSession extends BaseSession implements IVenueSession,
IChatRoomMessage m = ((IChatRoomMessageEvent) messageEvent)
.getChatRoomMessage();
distributeMessage(convertMessage(m));
if (accept(m)) {
distributeMessage(convertMessage(m));
}
}
}
};
@ -673,6 +674,34 @@ public class VenueSession extends BaseSession implements IVenueSession,
return errorStatus;
}
/**
* Examine the incoming message to determine if it should be forwarded. The
* method looks at the from identifier to determine who sent the message.
*
* @param message
* A message to accept.
* @return Should the message be accepted.
*/
private boolean accept(IChatRoomMessage message) {
boolean acceptMessage = true;
String body = message.getMessage();
// Command data only
if (body.startsWith(SEND_CMD)) {
ID from = message.getFromID();
String name = Tools.parseName(from.getName());
String host = Tools.parseHost(from.getName());
String account = getSessionManager().getAccount();
String aName = Tools.parseName(account);
if (aName.equals(name)) {
acceptMessage = false;
}
}
return acceptMessage;
}
/**
*
* @param message