コード例 #1
0
  public Map<String, Object> takeAdvice(ServerTransport transport) {
    if (transport != null && transport != _advisedTransport) {
      _advisedTransport = transport;

      // The timeout is calculated based on the values of the session/transport
      // because we want to send to the client the *next* timeout
      long timeout = getTimeout() < 0 ? transport.getTimeout() : getTimeout();

      // The interval is calculated using also the transient value
      // because we want to send to the client the *current* interval
      long interval = calculateInterval(transport.getInterval());

      Map<String, Object> advice = new HashMap<>(3);
      advice.put(Message.RECONNECT_FIELD, Message.RECONNECT_RETRY_VALUE);
      advice.put(Message.INTERVAL_FIELD, interval);
      advice.put(Message.TIMEOUT_FIELD, timeout);
      return advice;
    }

    // advice has not changed, so return null.
    return null;
  }