@Override
  public boolean sendMeta(ServerSession to, Mutable message) {
    String channel = message.getChannel();
    if (channel == null) return true;

    if (Channel.META_HANDSHAKE.equals(channel)
        && Boolean.TRUE.equals(message.get(Message.SUCCESSFUL_FIELD))) {
      Message rcv = message.getAssociated();

      Map<String, Object> ext = rcv.getExt();
      boolean clientRequestedAcks = ext != null && ext.get("ack") == Boolean.TRUE;

      if (clientRequestedAcks && to != null) {
        _logger.debug("Enabled message acknowledgement for client {}", to);
        to.addExtension(new AcknowledgedMessagesClientExtension(to));
        ((ServerSessionImpl) to).setMetaConnectDeliveryOnly(true);
      }

      Map<String, Object> mext = message.getExt();
      if (mext != null) mext.put("ack", Boolean.TRUE);
      else message.put(Message.EXT_FIELD, _replyExt);
    }

    return true;
  }
예제 #2
0
 @Override
 public boolean sendMeta(ServerSession to, Mutable message) {
   if (Channel.META_HANDSHAKE.equals(message.getChannel())
       || Channel.META_CONNECT.equals(message.getChannel())
       || Channel.META_DISCONNECT.equals(message.getChannel())) {
     AbstractHttpTransport transport = (AbstractHttpTransport) bayeux.getCurrentTransport();
     HttpServletRequest request = transport.getCurrentRequest();
     if (request != null) {
       String uri = request.getRequestURI();
       message.getExt(true).put("uri", uri);
     }
   }
   return true;
 }