Search in sources :

Example 1 with JsrEndpointEventDriver

use of org.eclipse.jetty.websocket.jsr356.endpoints.JsrEndpointEventDriver in project jetty.project by eclipse.

the class JsrServerExtendsEndpointImpl method create.

@Override
public EventDriver create(Object websocket, WebSocketPolicy policy) {
    if (!(websocket instanceof EndpointInstance)) {
        throw new IllegalStateException(String.format("Websocket %s must be an %s", websocket.getClass().getName(), EndpointInstance.class.getName()));
    }
    EndpointInstance ei = (EndpointInstance) websocket;
    JsrEndpointEventDriver driver = new JsrEndpointEventDriver(policy, ei);
    ServerEndpointConfig config = (ServerEndpointConfig) ei.getConfig();
    if (config instanceof PathParamServerEndpointConfig) {
        PathParamServerEndpointConfig ppconfig = (PathParamServerEndpointConfig) config;
        driver.setPathParameters(ppconfig.getPathParamMap());
    }
    return driver;
}
Also used : JsrEndpointEventDriver(org.eclipse.jetty.websocket.jsr356.endpoints.JsrEndpointEventDriver) ServerEndpointConfig(javax.websocket.server.ServerEndpointConfig) EndpointInstance(org.eclipse.jetty.websocket.jsr356.endpoints.EndpointInstance)

Example 2 with JsrEndpointEventDriver

use of org.eclipse.jetty.websocket.jsr356.endpoints.JsrEndpointEventDriver in project jetty.project by eclipse.

the class JsrSessionTest method initSession.

@Before
public void initSession() {
    container = new ClientContainer();
    String id = JsrSessionTest.class.getSimpleName();
    URI requestURI = URI.create("ws://localhost/" + id);
    WebSocketPolicy policy = WebSocketPolicy.newClientPolicy();
    ClientEndpointConfig config = new EmptyClientEndpointConfig();
    DummyEndpoint websocket = new DummyEndpoint();
    SimpleEndpointMetadata metadata = new SimpleEndpointMetadata(websocket.getClass());
    // Executor executor = null;
    EndpointInstance ei = new EndpointInstance(websocket, config, metadata);
    EventDriver driver = new JsrEndpointEventDriver(policy, ei);
    DummyConnection connection = new DummyConnection();
    session = new JsrSession(container, id, requestURI, driver, connection);
}
Also used : WebSocketPolicy(org.eclipse.jetty.websocket.api.WebSocketPolicy) DummyEndpoint(org.eclipse.jetty.websocket.jsr356.samples.DummyEndpoint) SimpleEndpointMetadata(org.eclipse.jetty.websocket.jsr356.client.SimpleEndpointMetadata) DummyConnection(org.eclipse.jetty.websocket.common.test.DummyConnection) EndpointInstance(org.eclipse.jetty.websocket.jsr356.endpoints.EndpointInstance) URI(java.net.URI) EmptyClientEndpointConfig(org.eclipse.jetty.websocket.jsr356.client.EmptyClientEndpointConfig) EventDriver(org.eclipse.jetty.websocket.common.events.EventDriver) JsrEndpointEventDriver(org.eclipse.jetty.websocket.jsr356.endpoints.JsrEndpointEventDriver) JsrEndpointEventDriver(org.eclipse.jetty.websocket.jsr356.endpoints.JsrEndpointEventDriver) EmptyClientEndpointConfig(org.eclipse.jetty.websocket.jsr356.client.EmptyClientEndpointConfig) ClientEndpointConfig(javax.websocket.ClientEndpointConfig) Before(org.junit.Before)

Aggregations

EndpointInstance (org.eclipse.jetty.websocket.jsr356.endpoints.EndpointInstance)2 JsrEndpointEventDriver (org.eclipse.jetty.websocket.jsr356.endpoints.JsrEndpointEventDriver)2 URI (java.net.URI)1 ClientEndpointConfig (javax.websocket.ClientEndpointConfig)1 ServerEndpointConfig (javax.websocket.server.ServerEndpointConfig)1 WebSocketPolicy (org.eclipse.jetty.websocket.api.WebSocketPolicy)1 EventDriver (org.eclipse.jetty.websocket.common.events.EventDriver)1 DummyConnection (org.eclipse.jetty.websocket.common.test.DummyConnection)1 EmptyClientEndpointConfig (org.eclipse.jetty.websocket.jsr356.client.EmptyClientEndpointConfig)1 SimpleEndpointMetadata (org.eclipse.jetty.websocket.jsr356.client.SimpleEndpointMetadata)1 DummyEndpoint (org.eclipse.jetty.websocket.jsr356.samples.DummyEndpoint)1 Before (org.junit.Before)1