use of jakarta.websocket.Extension in project spring-framework by spring-projects.
the class AbstractStandardUpgradeStrategy method upgrade.
@Override
public void upgrade(ServerHttpRequest request, ServerHttpResponse response, @Nullable String selectedProtocol, List<WebSocketExtension> selectedExtensions, @Nullable Principal user, WebSocketHandler wsHandler, Map<String, Object> attrs) throws HandshakeFailureException {
HttpHeaders headers = request.getHeaders();
InetSocketAddress localAddr = null;
try {
localAddr = request.getLocalAddress();
} catch (Exception ex) {
// Ignore
}
InetSocketAddress remoteAddr = null;
try {
remoteAddr = request.getRemoteAddress();
} catch (Exception ex) {
// Ignore
}
StandardWebSocketSession session = new StandardWebSocketSession(headers, attrs, localAddr, remoteAddr, user);
StandardWebSocketHandlerAdapter endpoint = new StandardWebSocketHandlerAdapter(wsHandler, session);
List<Extension> extensions = new ArrayList<>();
for (WebSocketExtension extension : selectedExtensions) {
extensions.add(new WebSocketToStandardExtensionAdapter(extension));
}
upgradeInternal(request, response, selectedProtocol, extensions, endpoint);
}
use of jakarta.websocket.Extension in project spring-framework by spring-projects.
the class StandardWebSocketSession method initializeNativeSession.
@Override
public void initializeNativeSession(Session session) {
super.initializeNativeSession(session);
this.uri = session.getRequestURI();
this.acceptedProtocol = session.getNegotiatedSubprotocol();
List<Extension> standardExtensions = getNativeSession().getNegotiatedExtensions();
if (!CollectionUtils.isEmpty(standardExtensions)) {
this.extensions = new ArrayList<>(standardExtensions.size());
for (Extension standardExtension : standardExtensions) {
this.extensions.add(new StandardToWebSocketExtensionAdapter(standardExtension));
}
this.extensions = Collections.unmodifiableList(this.extensions);
} else {
this.extensions = Collections.emptyList();
}
if (this.user == null) {
this.user = session.getUserPrincipal();
}
}
Aggregations