Package org.glassfish.tyrus.spi
Class Writer
java.lang.Object
org.glassfish.tyrus.spi.Writer
- All Implemented Interfaces:
Closeable
,AutoCloseable
- Direct Known Subclasses:
GrizzlyWriter
Writer class that is used by tyrus runtime to pass outbound websocket data
for a connection to a transport. Then, the transport actually writes the
data eventually.
A transport creates implementation of this class and registers the writer
object using WebSocketEngine.UpgradeInfo.createConnection(org.glassfish.tyrus.spi.Writer, org.glassfish.tyrus.spi.Connection.CloseListener)
after
a successful upgrade.
- Author:
- Pavel Bucek
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract void
write
(ByteBuffer buffer, CompletionHandler<ByteBuffer> completionHandler) A backward compatible method called fromwrite(ByteBuffer, CompletionHandler, WriterInfo)
to handover the data for a connection to the transport.void
write
(ByteBuffer buffer, CompletionHandler<ByteBuffer> completionHandler, WriterInfo writerInfo) Tyrus runtime calls this method to handover the data for a connection to the transport.
-
Constructor Details
-
Writer
public Writer()
-
-
Method Details
-
write
A backward compatible method called from
write(ByteBuffer, CompletionHandler, WriterInfo)
to handover the data for a connection to the transport. The transport writes bytes to underlying connection. Tyrus runtime must not use the buffer until the write is completed.The method will be removed in the next major version.
- Parameters:
buffer
- bytes to write.completionHandler
- completion handler to know the write status.
-
write
public void write(ByteBuffer buffer, CompletionHandler<ByteBuffer> completionHandler, WriterInfo writerInfo) Tyrus runtime calls this method to handover the data for a connection to the transport. The transport writes bytes to underlying connection. Tyrus runtime must not use the buffer until the write is completed.- Parameters:
buffer
- bytes to write.completionHandler
- completion handler to know the write status.writerInfo
- additional information about the data to be written.- Since:
- 1.17
-