Issue #437 - Corrected venue command message loopback
Former-commit-id:fad1fa7362
[formerly23a2cd033a
] [formerlyfad1fa7362
[formerly23a2cd033a
] [formerlye663a9e5dc
[formerly c3ba8bd9416f18358f2a976ee2104e4e614321c3]]] Former-commit-id:e663a9e5dc
Former-commit-id:9c924ccb25
[formerly44b07395fb
] Former-commit-id:27c2635ce2
This commit is contained in:
parent
0e37e6938f
commit
b1ca31467c
4 changed files with 80 additions and 31 deletions
|
@ -149,6 +149,40 @@ public abstract class BaseSession implements ISession {
|
||||||
return connectionPresence;
|
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()
|
* @see com.raytheon.uf.viz.collaboration.comm.identity.ISession#getUserID()
|
||||||
*/
|
*/
|
||||||
|
@ -230,21 +264,4 @@ public abstract class BaseSession implements ISession {
|
||||||
return eventBus;
|
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,9 +76,6 @@ public class PeerToPeerCommHelper implements IIMMessageListener {
|
||||||
@Override
|
@Override
|
||||||
public void handleMessageEvent(IIMMessageEvent messageEvent) {
|
public void handleMessageEvent(IIMMessageEvent messageEvent) {
|
||||||
|
|
||||||
System.out.println("Handling event "
|
|
||||||
+ messageEvent.getClass().getName());
|
|
||||||
|
|
||||||
if (messageEvent instanceof IChatMessageEvent) {
|
if (messageEvent instanceof IChatMessageEvent) {
|
||||||
IChatMessageEvent event = (IChatMessageEvent) messageEvent;
|
IChatMessageEvent event = (IChatMessageEvent) messageEvent;
|
||||||
System.out.println(" message event.body "
|
System.out.println(" message event.body "
|
||||||
|
@ -95,10 +92,6 @@ public class PeerToPeerCommHelper implements IIMMessageListener {
|
||||||
routeMessage(msg);
|
routeMessage(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if(messageEvent != null) {
|
|
||||||
System.out.println(messageEvent.getClass().getName() + " trapped in PeerToPeerCommHelper");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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.
|
* Get the account manager for this connection.
|
||||||
*
|
*
|
||||||
|
@ -353,8 +361,10 @@ public class SessionManager implements IEventPublisher {
|
||||||
if (session != null) {
|
if (session != null) {
|
||||||
session.createVenue(venueName, subject);
|
session.createVenue(venueName, subject);
|
||||||
|
|
||||||
IChatID me = new VenueUserId("jkorman",
|
String name = Tools.parseName(account);
|
||||||
"awipscm.omaha.us.ray.com");
|
String host = Tools.parseHost(account);
|
||||||
|
|
||||||
|
IChatID me = new VenueUserId(name, host);
|
||||||
|
|
||||||
session.setSessionLeader(me);
|
session.setSessionLeader(me);
|
||||||
session.setSessionDataProvider(me);
|
session.setSessionDataProvider(me);
|
||||||
|
|
|
@ -149,7 +149,6 @@ public class VenueSession extends BaseSession implements IVenueSession,
|
||||||
VenueSession(IContainer container, EventBus externalBus,
|
VenueSession(IContainer container, EventBus externalBus,
|
||||||
SessionManager manager) throws CollaborationException {
|
SessionManager manager) throws CollaborationException {
|
||||||
super(container, externalBus, manager);
|
super(container, externalBus, manager);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -352,10 +351,10 @@ public class VenueSession extends BaseSession implements IVenueSession,
|
||||||
if (session != null) {
|
if (session != null) {
|
||||||
String message = Tools.marshallData(initData);
|
String message = Tools.marshallData(initData);
|
||||||
if (message != null) {
|
if (message != null) {
|
||||||
|
|
||||||
TextMessage msg = new TextMessage(participant, message);
|
TextMessage msg = new TextMessage(participant, message);
|
||||||
msg.setProperty(Tools.PROP_SESSION_ID, getSessionId());
|
msg.setProperty(Tools.PROP_SESSION_ID, getSessionId());
|
||||||
|
|
||||||
session.sendPeerToPeer(msg);
|
session.sendPeerToPeer(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -414,7 +413,7 @@ public class VenueSession extends BaseSession implements IVenueSession,
|
||||||
if (session != null) {
|
if (session != null) {
|
||||||
String message = Tools.marshallData(event);
|
String message = Tools.marshallData(event);
|
||||||
if (message != null) {
|
if (message != null) {
|
||||||
|
|
||||||
TextMessage msg = new TextMessage(participant, message);
|
TextMessage msg = new TextMessage(participant, message);
|
||||||
msg.setProperty(Tools.PROP_SESSION_ID, getSessionId());
|
msg.setProperty(Tools.PROP_SESSION_ID, getSessionId());
|
||||||
session.sendPeerToPeer(msg);
|
session.sendPeerToPeer(msg);
|
||||||
|
@ -659,7 +658,9 @@ public class VenueSession extends BaseSession implements IVenueSession,
|
||||||
IChatRoomMessage m = ((IChatRoomMessageEvent) messageEvent)
|
IChatRoomMessage m = ((IChatRoomMessageEvent) messageEvent)
|
||||||
.getChatRoomMessage();
|
.getChatRoomMessage();
|
||||||
|
|
||||||
distributeMessage(convertMessage(m));
|
if (accept(m)) {
|
||||||
|
distributeMessage(convertMessage(m));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -673,6 +674,34 @@ public class VenueSession extends BaseSession implements IVenueSession,
|
||||||
return errorStatus;
|
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
|
* @param message
|
||||||
|
|
Loading…
Add table
Reference in a new issue