Class MessageInputStream

java.lang.Object
java.io.InputStream
org.eclipse.jetty.websocket.core.messages.MessageInputStream
All Implemented Interfaces:
Closeable, AutoCloseable, MessageSink

public class MessageInputStream extends InputStream implements MessageSink
Support class for reading a WebSocket BINARY message via a InputStream.

An InputStream that can access a queue of ByteBuffer payloads, along with expected InputStream blocking behavior.

  • Constructor Details

    • MessageInputStream

      public MessageInputStream(CoreSession session)
  • Method Details

    • accept

      public void accept(Frame frame, Callback callback)
      Description copied from interface: MessageSink

      Consumes the WebSocket frame, possibly asynchronously when this method has returned.

      The callback argument must be completed when the frame payload is consumed.

      The demand for more frames must be explicitly invoked, or arranged to be invoked asynchronously, by the implementation of this method, by calling CoreSession.demand().

      Specified by:
      accept in interface MessageSink
      Parameters:
      frame - the frame to consume
      callback - the callback to complete when the frame is consumed
    • read

      public int read() throws IOException
      Specified by:
      read in class InputStream
      Throws:
      IOException
    • read

      public int read(byte[] b, int off, int len) throws IOException
      Overrides:
      read in class InputStream
      Throws:
      IOException
    • read

      public int read(ByteBuffer buffer) throws IOException
      Throws:
      IOException
    • fail

      public void fail(Throwable failure)
      Description copied from interface: MessageSink

      Fails this MessageSink with the given cause.

      Specified by:
      fail in interface MessageSink
      Parameters:
      failure - the cause of the failure
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class InputStream
    • setTimeout

      public void setTimeout(long timeoutMs)