class StreamConnection implements Closeable {

  public UnsignedLong nextSequence() throws StreamConnectionClosedException {
    // Unique per-thread.
    final UnsignedLong nextSequence = sequence.getAndUpdate(currentSequence -> currentSequence.plus(UnsignedLong.ONE));
    if (sequenceIsSafeForSingleSharedSecret(nextSequence)) {
      return nextSequence;
    } else {
      this.closeConnection();
      throw new StreamConnectionClosedException(streamConnectionId);
    }
  }

  public  StreamConnection(final InterledgerAddress receiverAddress, final SharedSecret sharedSecret);
  public  StreamConnection(final StreamConnectionId streamConnectionId);

}