Class MessageInputStream
- java.lang.Object
-
- java.io.InputStream
-
- org.eclipse.jetty.websocket.common.message.MessageInputStream
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,MessageAppender
public class MessageInputStream extends java.io.InputStream implements MessageAppender
Support class for reading a (single) WebSocket BINARY message via a InputStream.An InputStream that can access a queue of ByteBuffer payloads, along with expected InputStream blocking behavior.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
MessageInputStream.State
-
Field Summary
Fields Modifier and Type Field Description private java.nio.ByteBuffer
activeBuffer
private org.eclipse.jetty.io.ByteBufferPool
bufferPool
private java.util.concurrent.BlockingDeque<java.nio.ByteBuffer>
buffers
private static java.nio.ByteBuffer
EOF
private static org.eclipse.jetty.util.log.Logger
LOG
private Session
session
private MessageInputStream.State
state
private SuspendToken
suspendToken
private long
timeoutMs
-
Constructor Summary
Constructors Constructor Description MessageInputStream(Session session)
MessageInputStream(Session session, int timeoutMs)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.nio.ByteBuffer
acquire(int capacity, boolean direct)
void
appendFrame(java.nio.ByteBuffer framePayload, boolean fin)
Append the frame payload to the message.void
close()
void
handlerComplete()
void
mark(int readlimit)
boolean
markSupported()
void
messageComplete()
Notification that message is to be considered complete.int
read()
int
read(byte[] b, int off, int len)
void
reset()
-
-
-
Field Detail
-
LOG
private static final org.eclipse.jetty.util.log.Logger LOG
-
EOF
private static final java.nio.ByteBuffer EOF
-
session
private final Session session
-
bufferPool
private final org.eclipse.jetty.io.ByteBufferPool bufferPool
-
buffers
private final java.util.concurrent.BlockingDeque<java.nio.ByteBuffer> buffers
-
timeoutMs
private final long timeoutMs
-
activeBuffer
private java.nio.ByteBuffer activeBuffer
-
suspendToken
private SuspendToken suspendToken
-
state
private MessageInputStream.State state
-
-
Method Detail
-
appendFrame
public void appendFrame(java.nio.ByteBuffer framePayload, boolean fin) throws java.io.IOException
Description copied from interface:MessageAppender
Append the frame payload to the message.- Specified by:
appendFrame
in interfaceMessageAppender
- Parameters:
framePayload
- the frame payload to append.fin
- flag indicating if this is the last part of the message or not.- Throws:
java.io.IOException
- if unable to append the frame payload
-
close
public void close()
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classjava.io.InputStream
-
handlerComplete
public void handlerComplete()
-
read
public int read() throws java.io.IOException
- Specified by:
read
in classjava.io.InputStream
- Throws:
java.io.IOException
-
read
public int read(byte[] b, int off, int len) throws java.io.IOException
- Overrides:
read
in classjava.io.InputStream
- Throws:
java.io.IOException
-
messageComplete
public void messageComplete()
Description copied from interface:MessageAppender
Notification that message is to be considered complete.Any cleanup or final actions should be taken here.
- Specified by:
messageComplete
in interfaceMessageAppender
-
reset
public void reset() throws java.io.IOException
- Overrides:
reset
in classjava.io.InputStream
- Throws:
java.io.IOException
-
mark
public void mark(int readlimit)
- Overrides:
mark
in classjava.io.InputStream
-
markSupported
public boolean markSupported()
- Overrides:
markSupported
in classjava.io.InputStream
-
acquire
private java.nio.ByteBuffer acquire(int capacity, boolean direct)
-
-