Top Description Fields Constructors Methods
org.springframework.web.reactive.socket.adapter

public Class StandardWebSocketHandlerAdapter

extends Endpoint
Class Inheritance
Imports
java.nio.ByteBuffer, java.nio.charset.StandardCharsets, java.util.function.Function, jakarta.websocket.CloseReason, .Endpoint, .EndpointConfig, .PongMessage, .Session, org.springframework.core.io.buffer.DataBuffer, org.springframework.lang.Nullable, org.springframework.util.Assert, org.springframework.web.reactive.socket.CloseStatus, .WebSocketHandler, .WebSocketMessage, .WebSocketMessage.Type, .WebSocketSession

Adapter for the Jakarta WebSocket API (JSR-356) that delegates events to a reactive WebSocketHandler and its session.
Authors
Violeta Georgieva, Rossen Stoyanchev, Sam Brannen
Since
5.0

Field Summary

Modifier and TypeField and Description
private final WebSocketHandler
private StandardWebSocketSession
private final Function<Session, StandardWebSocketSession>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
onClose(Session
The session
session
,
CloseReason
Why the session was closed
reason
)

Overrides jakarta.websocket.Endpoint.onClose.

Event that is triggered when a session has closed.

public void
onError(Session
The session.
session
,
Throwable
The exception.
exception
)

Overrides jakarta.websocket.Endpoint.onError.

Event that is triggered when a protocol error occurs.

public void
onOpen(Session
The new session.
session
,
EndpointConfig
The configuration with which the Endpoint was configured.
config
)

Implements abstract jakarta.websocket.Endpoint.onOpen.

Event that is triggered when a new session starts.

private <T> WebSocketMessage
toMessage(T message)

Field Detail

delegateHandlerback to summary
private final WebSocketHandler delegateHandler
delegateSessionback to summary
private StandardWebSocketSession delegateSession
Annotations
@Nullable
sessionFactoryback to summary
private final Function<Session, StandardWebSocketSession> sessionFactory

Constructor Detail

StandardWebSocketHandlerAdapterback to summary
public StandardWebSocketHandlerAdapter(WebSocketHandler handler, Function<Session, StandardWebSocketSession> sessionFactory)

Method Detail

onCloseback to summary
public void onClose(Session session, CloseReason reason)

Overrides jakarta.websocket.Endpoint.onClose.

Doc from jakarta.websocket.Endpoint.onClose.

Event that is triggered when a session has closed.

Parameters
session:Session

The session

reason:CloseReason

Why the session was closed

Annotations
@Override
onErrorback to summary
public void onError(Session session, Throwable exception)

Overrides jakarta.websocket.Endpoint.onError.

Doc from jakarta.websocket.Endpoint.onError.

Event that is triggered when a protocol error occurs.

Parameters
session:Session

The session.

exception:Throwable

The exception.

Annotations
@Override
onOpenback to summary
public void onOpen(Session session, EndpointConfig config)

Implements abstract jakarta.websocket.Endpoint.onOpen.

Doc from jakarta.websocket.Endpoint.onOpen.

Event that is triggered when a new session starts.

Parameters
session:Session

The new session.

config:EndpointConfig

The configuration with which the Endpoint was configured.

Annotations
@Override
toMessageback to summary
private <T> WebSocketMessage toMessage(T message)