Search in sources :

Example 21 with Extension

use of javax.websocket.Extension in project spring-framework by spring-projects.

the class StandardWebSocketSession method initializeNativeSession.

@Override
public void initializeNativeSession(Session session) {
    super.initializeNativeSession(session);
    this.id = session.getId();
    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();
    }
}
Also used : Extension(javax.websocket.Extension) WebSocketExtension(org.springframework.web.socket.WebSocketExtension)

Example 22 with Extension

use of javax.websocket.Extension in project undertow by undertow-io.

the class ServerWebSocketContainer method toExtensionList.

private static List<WebSocketExtension> toExtensionList(final List<Extension> extensions) {
    List<WebSocketExtension> ret = new ArrayList<>();
    for (Extension e : extensions) {
        final List<WebSocketExtension.Parameter> parameters = new ArrayList<>();
        for (Extension.Parameter p : e.getParameters()) {
            parameters.add(new WebSocketExtension.Parameter(p.getName(), p.getValue()));
        }
        ret.add(new WebSocketExtension(e.getName(), parameters));
    }
    return ret;
}
Also used : WebSocketExtension(io.undertow.websockets.WebSocketExtension) Extension(javax.websocket.Extension) WebSocketExtension(io.undertow.websockets.WebSocketExtension) ArrayList(java.util.ArrayList)

Aggregations

Extension (javax.websocket.Extension)22 ArrayList (java.util.ArrayList)16 ClientEndpointConfig (javax.websocket.ClientEndpointConfig)6 URI (java.net.URI)5 WebSocketExtension (io.undertow.websockets.WebSocketExtension)4 DeploymentException (javax.websocket.DeploymentException)4 Endpoint (javax.websocket.Endpoint)4 Parameter (javax.websocket.Extension.Parameter)4 Session (javax.websocket.Session)4 IOException (java.io.IOException)3 InetSocketAddress (java.net.InetSocketAddress)3 HashMap (java.util.HashMap)3 List (java.util.List)3 CountDownLatch (java.util.concurrent.CountDownLatch)3 ServerEndpointConfig (javax.websocket.server.ServerEndpointConfig)3 JsrExtension (org.eclipse.jetty.websocket.jsr356.JsrExtension)3 WebSocketChannel (io.undertow.websockets.core.WebSocketChannel)2 ExtensionHandshake (io.undertow.websockets.extensions.ExtensionHandshake)2 HashSet (java.util.HashSet)2 ExecutionException (java.util.concurrent.ExecutionException)2