Пример #1
0
  protected Object perRequestFilter(AtmosphereResource<?, ?> r, Entry msg) {
    Object finalMsg = msg.message;

    if (AtmosphereResourceImpl.class.isAssignableFrom(r.getClass())) {
      if (AtmosphereResourceImpl.class.cast(r).isInScope()) {
        if (r.getRequest() instanceof HttpServletRequest && bc.hasPerRequestFilters()) {
          Object message = msg.originalMessage;
          BroadcastAction a =
              bc.filter(
                  (HttpServletRequest) r.getRequest(),
                  (HttpServletResponse) r.getResponse(),
                  message);
          if (a.action() == BroadcastAction.ACTION.ABORT || a.message() != msg.originalMessage) {
            finalMsg = a.message();
          }
        }
        trackBroadcastMessage(r, finalMsg);
      } else {
        // The resource is no longer valid.
        removeAtmosphereResource(r);
        BroadcasterFactory.getDefault().removeAllAtmosphereResource(r);
      }
    }
    return finalMsg;
  }
Пример #2
0
 /**
  * Invoke the {@link BroadcastFilter}
  *
  * @param msg
  * @return
  */
 protected Object filter(Object msg) {
   BroadcastAction a = bc.filter(msg);
   if (a.action() == BroadcastAction.ACTION.ABORT || msg == null) return null;
   else return a.message();
 }