Package org.atmosphere.webtransport
Class WebTransportSession
java.lang.Object
org.atmosphere.cpr.AsyncIOWriterAdapter
org.atmosphere.cpr.AtmosphereInterceptorWriter
org.atmosphere.webtransport.WebTransportSession
- All Implemented Interfaces:
AsyncIOWriter,KeepOpenStreamAware
public abstract class WebTransportSession
extends AtmosphereInterceptorWriter
implements KeepOpenStreamAware
Abstract representation of a WebTransport bidirectional stream session.
Mirrors
WebSocket for WebTransport over
HTTP/3, backed by a single QUIC bidirectional stream.
Unlike WebSocket, there is no application-level ping/pong — QUIC handles keep-alive at the transport layer. Close codes use HTTP/3 error codes (0-255), not WebSocket codes (1000-4999).
Concrete implementations are provided by container modules (e.g., the Spring Boot starter's Reactor Netty integration).
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanstatic final Stringprotected longprotected static final org.slf4j.Loggerstatic final Stringprotected Stringstatic final Stringstatic final StringFields inherited from class org.atmosphere.cpr.AtmosphereInterceptorWriter
filters, reversedFilters -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionattachment(Object attachment) Broadcast an object to all sessions sharing this resource'sBroadcaster.abstract voidclose()Close the session.voidClose with an HTTP/3 error code and reason.voidClose the underlying connection.config()Flush the buffered content.abstract booleanisOpen()Whether the underlying QUIC stream is still open.longstatic voidnotSupported(AtmosphereRequest request, AtmosphereResponse response) redirect(AtmosphereResponse r, String location) Redirect a WebSocket request to another location.resource()Associate anAtmosphereResourcewith this session.voidSnapshot the request attributes that were set when the session opened.protected byte[]transform(AtmosphereResponse response, byte[] b, int offset, int length) uuid()protected WebTransportSessionwebTransportHandler(WebTransportHandler handler) write(byte[] b) Write binary data to the bidirectional stream.abstract WebTransportSessionwrite(byte[] b, int offset, int length) Write binary data to the bidirectional stream.abstract WebTransportSessionWrite a text message to the bidirectional stream.write(AtmosphereResponse r, byte[] data) Write a WebSocket message.write(AtmosphereResponse r, byte[] b, int offset, int length) Write a WebSocket message.write(AtmosphereResponse r, String data) Write a WebSocket message.writeError(AtmosphereResponse r, int errorCode, String message) Write an error code.Methods inherited from class org.atmosphere.cpr.AtmosphereInterceptorWriter
filters, interceptor, interceptor, invokeInterceptor, writeReady
-
Field Details
-
logger
protected static final org.slf4j.Logger logger -
WEBTRANSPORT_INITIATED
-
WEBTRANSPORT_SUSPEND
-
NOT_SUPPORTED
- See Also:
-
CLEAN_CLOSE
- See Also:
-
lastWrite
protected long lastWrite -
binaryWrite
protected boolean binaryWrite -
uuid
-
-
Constructor Details
-
WebTransportSession
-
-
Method Details
-
config
-
webTransportHandler
-
webTransportHandler
-
resource
Associate anAtmosphereResourcewith this session.- Parameters:
r- the resource- Returns:
- this
-
resource
-
shiftAttributes
public void shiftAttributes()Snapshot the request attributes that were set when the session opened. -
attributes
-
uuid
-
lastWriteTimeStampInMilliseconds
public long lastWriteTimeStampInMilliseconds() -
broadcast
Broadcast an object to all sessions sharing this resource'sBroadcaster. -
write
Description copied from interface:AsyncIOWriterWrite a WebSocket message.- Specified by:
writein interfaceAsyncIOWriter- Overrides:
writein classAtmosphereInterceptorWriter- Parameters:
data- the WebSocket message- Throws:
IOException
-
write
Description copied from interface:AsyncIOWriterWrite a WebSocket message.- Specified by:
writein interfaceAsyncIOWriter- Overrides:
writein classAtmosphereInterceptorWriter- Parameters:
data- the WebSocket message- Throws:
IOException
-
write
public WebTransportSession write(AtmosphereResponse r, byte[] b, int offset, int length) throws IOException Description copied from interface:AsyncIOWriterWrite a WebSocket message.- Specified by:
writein interfaceAsyncIOWriter- Overrides:
writein classAtmosphereInterceptorWriter- Parameters:
b- the WebSocket messageoffset- offset of the messagelength- length of the message- Throws:
IOException
-
writeError
public WebTransportSession writeError(AtmosphereResponse r, int errorCode, String message) throws IOException Description copied from interface:AsyncIOWriterWrite an error code.- Specified by:
writeErrorin interfaceAsyncIOWriter- Overrides:
writeErrorin classAtmosphereInterceptorWriter- Parameters:
errorCode- the error codemessage-- Throws:
IOException
-
redirect
Description copied from interface:AsyncIOWriterRedirect a WebSocket request to another location.- Specified by:
redirectin interfaceAsyncIOWriter- Overrides:
redirectin classAtmosphereInterceptorWriter- Parameters:
location-- Throws:
IOException
-
close
Description copied from interface:AsyncIOWriterClose the underlying connection.- Specified by:
closein interfaceAsyncIOWriter- Overrides:
closein classAtmosphereInterceptorWriter- Throws:
IOException
-
flush
Description copied from interface:AsyncIOWriterFlush the buffered content.- Specified by:
flushin interfaceAsyncIOWriter- Overrides:
flushin classAtmosphereInterceptorWriter- Throws:
IOException
-
notSupported
public static void notSupported(AtmosphereRequest request, AtmosphereResponse response) throws IOException - Throws:
IOException
-
attachment
-
attachment
-
transform
protected byte[] transform(AtmosphereResponse response, byte[] b, int offset, int length) throws IOException - Throws:
IOException
-
isOpen
public abstract boolean isOpen()Whether the underlying QUIC stream is still open. -
write
Write a text message to the bidirectional stream.- Throws:
IOException
-
write
Write binary data to the bidirectional stream.- Throws:
IOException
-
write
Write binary data to the bidirectional stream.- Throws:
IOException
-
close
public abstract void close()Close the session. -
close
Close with an HTTP/3 error code and reason.- Parameters:
errorCode- HTTP/3 error code (0-255)reason- human-readable reason
-