Class AbstractStream.TransportState

    • Field Detail

      • onReadyLock

        private final java.lang.Object onReadyLock
      • numSentBytesQueued

        private int numSentBytesQueued
        The number of bytes currently queued, waiting to be sent. When this falls below DEFAULT_ONREADY_THRESHOLD, StreamListener.onReady() will be called.
      • allocated

        private boolean allocated
        Indicates the stream has been created on the connection. This implies that the stream is no longer limited by MAX_CONCURRENT_STREAMS.
      • deallocated

        private boolean deallocated
        Indicates that the stream no longer exists for the transport. Implies that the application should be discouraged from sending, because doing so would have no effect.
      • onReadyThreshold

        private int onReadyThreshold
    • Method Detail

      • optimizeForDirectExecutor

        final void optimizeForDirectExecutor()
      • setFullStreamDecompressor

        protected void setFullStreamDecompressor​(GzipInflatingBuffer fullStreamDecompressor)
      • setMaxInboundMessageSize

        final void setMaxInboundMessageSize​(int maxSize)
      • listener

        protected abstract StreamListener listener()
        Override this method to provide a stream listener.
      • setOnReadyThreshold

        void setOnReadyThreshold​(int numBytes)
        A hint to the stream that specifies how many bytes must be queued before isReady() will return false. A stream may ignore this property if unsupported. This may only be set before any messages are sent.
        Parameters:
        numBytes - The number of bytes that must be queued. Must be a positive integer.
      • closeDeframer

        protected final void closeDeframer​(boolean stopDelivery)
        Closes the deframer and frees any resources. After this method is called, additional calls will have no effect.

        When stopDelivery is false, the deframer will wait to close until any already queued messages have been delivered.

        The deframer will invoke ApplicationThreadDeframerListener.deframerClosed(boolean) upon closing.

        Parameters:
        stopDelivery - interrupt pending deliveries and close immediately
      • deframe

        protected final void deframe​(ReadableBuffer frame)
        Called to parse a received frame and attempt delivery of any completed messages. Must be called from the transport thread.
      • requestMessagesFromDeframer

        private void requestMessagesFromDeframer​(int numMessages)
        Called to request the given number of messages from the deframer. May be called from any thread.
      • requestMessagesFromDeframerForTesting

        public final void requestMessagesFromDeframerForTesting​(int numMessages)
        Very rarely used. Prefer stream.request() instead of this; this method is only necessary if a stream is not available.
      • setDecompressor

        protected final void setDecompressor​(Decompressor decompressor)
      • isReady

        private boolean isReady()
      • onStreamAllocated

        protected void onStreamAllocated()
        Event handler to be called by the subclass when the stream's headers have passed any connection flow control (i.e., MAX_CONCURRENT_STREAMS). It may call the listener's StreamListener.onReady() handler if appropriate. This must be called from the transport thread, since the listener may be called back directly.
      • onStreamDeallocated

        protected final void onStreamDeallocated()
        Notify that the stream does not exist in a usable state any longer. This causes AbstractStream.isReady() to return false from this point forward.

        This does not generally need to be called explicitly by the transport, as it is handled implicitly by AbstractClientStream and AbstractServerStream.

      • isStreamDeallocated

        protected boolean isStreamDeallocated()
      • onSendingBytes

        private void onSendingBytes​(int numBytes)
        Event handler to be called by the subclass when a number of bytes are being queued for sending to the remote endpoint.
        Parameters:
        numBytes - the number of bytes being sent.
      • onSentBytes

        public final void onSentBytes​(int numBytes)
        Event handler to be called by the subclass when a number of bytes has been sent to the remote endpoint. May call back the listener's StreamListener.onReady() handler if appropriate. This must be called from the transport thread, since the listener may be called back directly.
        Parameters:
        numBytes - the number of bytes that were sent.
      • notifyIfReady

        private void notifyIfReady()