コード例 #1
0
  protected ServerSessionImpl(
      BayeuxServerImpl bayeux, LocalSessionImpl localSession, String idHint) {
    _bayeux = bayeux;
    _localSession = localSession;

    StringBuilder id = new StringBuilder(30);
    int len = 20;
    if (idHint != null) {
      len += idHint.length() + 1;
      id.append(idHint);
      id.append('_');
    }
    int index = id.length();

    while (id.length() < len) {
      long random = _bayeux.randomLong();
      id.append(Long.toString(random < 0 ? -random : random, 36));
    }

    id.insert(index, Long.toString(_idCount.incrementAndGet(), 36));

    _id = id.toString();

    ServerTransport transport = _bayeux.getCurrentTransport();
    if (transport != null)
      _intervalTimestamp = System.currentTimeMillis() + transport.getMaxInterval();

    _broadcastToPublisher = _bayeux.isBroadcastToPublisher();
  }