Search in sources :

Example 6 with EventDriver

use of org.eclipse.jetty.websocket.common.events.EventDriver 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)

Example 7 with EventDriver

use of org.eclipse.jetty.websocket.common.events.EventDriver in project jetty.project by eclipse.

the class MessageOutputStreamTest method setupSession.

@Before
public void setupSession() throws Exception {
    policy = WebSocketPolicy.newServerPolicy();
    policy.setInputBufferSize(1024);
    policy.setMaxBinaryMessageBufferSize(1024);
    // Container
    WebSocketContainerScope containerScope = new SimpleContainerScope(policy, bufferPool);
    // Event Driver factory
    EventDriverFactory factory = new EventDriverFactory(containerScope);
    // local socket
    EventDriver driver = factory.wrap(new TrackingSocket("local"));
    // remote socket
    socket = new TrackingSocket("remote");
    OutgoingFrames socketPipe = FramePipes.to(factory.wrap(socket));
    session = new LocalWebSocketSession(containerScope, testname, driver);
    session.setPolicy(policy);
    // talk to our remote socket
    session.setOutgoingHandler(socketPipe);
    // start session
    session.start();
    // open connection
    session.open();
}
Also used : EventDriver(org.eclipse.jetty.websocket.common.events.EventDriver) LocalWebSocketSession(org.eclipse.jetty.websocket.common.io.LocalWebSocketSession) EventDriverFactory(org.eclipse.jetty.websocket.common.events.EventDriverFactory) WebSocketContainerScope(org.eclipse.jetty.websocket.common.scopes.WebSocketContainerScope) OutgoingFrames(org.eclipse.jetty.websocket.api.extensions.OutgoingFrames) SimpleContainerScope(org.eclipse.jetty.websocket.common.scopes.SimpleContainerScope) Before(org.junit.Before)

Aggregations

EventDriver (org.eclipse.jetty.websocket.common.events.EventDriver)7 WebSocketPolicy (org.eclipse.jetty.websocket.api.WebSocketPolicy)3 EventDriverFactory (org.eclipse.jetty.websocket.common.events.EventDriverFactory)3 SimpleContainerScope (org.eclipse.jetty.websocket.common.scopes.SimpleContainerScope)3 WebSocketContainerScope (org.eclipse.jetty.websocket.common.scopes.WebSocketContainerScope)3 Before (org.junit.Before)3 URI (java.net.URI)2 ClientEndpointConfig (javax.websocket.ClientEndpointConfig)2 OutgoingFrames (org.eclipse.jetty.websocket.api.extensions.OutgoingFrames)2 LocalWebSocketSession (org.eclipse.jetty.websocket.common.io.LocalWebSocketSession)2 DummyConnection (org.eclipse.jetty.websocket.common.test.DummyConnection)2 AnnotatedEndpointScanner (org.eclipse.jetty.websocket.jsr356.annotations.AnnotatedEndpointScanner)2 EndpointInstance (org.eclipse.jetty.websocket.jsr356.endpoints.EndpointInstance)2 Test (org.junit.Test)2 IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1 ArrayList (java.util.ArrayList)1 ClientEndpoint (javax.websocket.ClientEndpoint)1 ServerEndpoint (javax.websocket.server.ServerEndpoint)1 ServerEndpointConfig (javax.websocket.server.ServerEndpointConfig)1