Notify only client subscribed to the active channel.
ArrayList<Throwable> exceptions = null;
CometHandler handler = null;
Object o = cometEvent.attachment();
String activeChannel = "";
String channel = "";
if (o instanceof Data){
activeChannel = ((Data)o).getChannel();
} else if (o instanceof DataHandler){
activeChannel = ((DataHandler)o).getChannel();
}
while(iteratorHandlers.hasNext()){
try{
handler = (CometHandler)iteratorHandlers.next();
if (handler instanceof CometdHandler){
channel = ((CometdHandler)handler).getChannel();
} else if (handler instanceof DataHandler){
channel = ((DataHandler)handler).getChannel();
}
if (channel != null
&& channel.equals(BayeuxCometHandler.BAYEUX_COMET_HANDLER)
|| channel.equalsIgnoreCase(activeChannel)){
notify0(cometEvent,handler);
} else if (channel == null){
CometEngine.logger().log(Level.WARNING,"Channel was null");
}
} catch (Throwable ex){
if (exceptions == null){
exceptions = new ArrayList<Throwable>();
}
exceptions.add(ex);
}
}
if (exceptions != null){
StringBuffer errorMsg = new StringBuffer();
for(Throwable t: exceptions){
errorMsg.append(t.getMessage());
}
throw new IOException(errorMsg.toString());
}