Package org.atmosphere.websocket

Examples of org.atmosphere.websocket.WebSocket


    @Test
    public void testManagedWebSocketPathMessage() throws IOException, ServletException {
        instanceCount = 0;

        ByteArrayOutputStream b = new ByteArrayOutputStream();
        final WebSocket w = new ArrayBaseWebSocket(b);
        final WebSocketProcessor processor = WebSocketProcessorFactory.getDefault()
                .getWebSocketProcessor(framework);

        AtmosphereRequest request = new AtmosphereRequest.Builder().pathInfo("/ws/bar").method("GET").build();
        processor.open(w, request, AtmosphereResponse.newInstance(framework.getAtmosphereConfig(), request, w));
View Full Code Here


    @Test
    public void testSingletonManagedWebSocketPathMessage() throws IOException, ServletException {
        instanceCount = 0;

        ByteArrayOutputStream b = new ByteArrayOutputStream();
        final WebSocket w = new ArrayBaseWebSocket(b);
        final WebSocketProcessor processor = WebSocketProcessorFactory.getDefault()
                .getWebSocketProcessor(framework);

        AtmosphereRequest request = new AtmosphereRequest.Builder().pathInfo("/singleton/ws/bar").method("GET").build();
        processor.open(w, request, AtmosphereResponse.newInstance(framework.getAtmosphereConfig(), request, w));
View Full Code Here

                        logger.debug("IdleResourceInterceptor disconnecting {}", r);
                        Future<?> f = (Future<?>) req.getAttribute(HeartbeatInterceptor.HEARTBEAT_FUTURE);
                        if (f != null) f.cancel(false);
                        req.removeAttribute(HeartbeatInterceptor.HEARTBEAT_FUTURE);

                        WebSocket webSocket = AtmosphereResourceImpl.class.cast(r).webSocket();
                        if (webSocket != null) {
                            webSocket.close();
                        } else {
                            AsynchronousProcessor.class.cast(config.framework().getAsyncSupport()).endRequest(AtmosphereResourceImpl.class.cast(r), true);
                        }
                    } finally {
                        config.getBroadcasterFactory().removeAllAtmosphereResource(r);
View Full Code Here

    public void onOpen(WebSocketConnection webSocketConnection) {
        if (webSocketWriteTimeout != -1)
            webSocketConnection.getWebSocketContext().setTimeoutSecs(webSocketWriteTimeout);
        if (maxTextBufferSize != -1) webSocketConnection.getWebSocketContext().setMaxMessageSize(maxTextBufferSize);

        WebSocket webSocket = new WebLogicWebSocket(webSocketConnection, config);
        // TODO: Dangerous
        webSocketConnection.getWebSocketContext().getServletContext().setAttribute(webSocketConnection.toString(), webSocket);

        AtmosphereRequest ar = AtmosphereRequest.cloneRequest(request.get(), true, false, true);
        request.set(null);
View Full Code Here

    }

    @Override
    public void onMessage(WebSocketConnection webSocketConnection, String s) {
        WebSocket webSocket = (WebSocket) webSocketConnection.getWebSocketContext().getServletContext().getAttribute(webSocketConnection.toString());

        webSocketProcessor.invokeWebSocketProtocol(webSocket, s);
    }
View Full Code Here

        webSocketProcessor.invokeWebSocketProtocol(webSocket, s);
    }

    @Override
    public void onMessage(WebSocketConnection webSocketConnection, byte[] bytes) {
        WebSocket webSocket = (WebSocket) webSocketConnection.getWebSocketContext().getServletContext().getAttribute(webSocketConnection.toString());

        webSocketProcessor.invokeWebSocketProtocol(webSocket, bytes, 0, bytes.length);
    }
View Full Code Here

        logger.trace("Warning, Fragment not supported");
    }

    @Override
    public void onTimeout(WebSocketConnection webSocketConnection) {
        WebSocket webSocket = (WebSocket) webSocketConnection.getWebSocketContext().getServletContext().getAttribute(webSocketConnection.toString());

        webSocketProcessor.close(webSocket, 1000);
    }
View Full Code Here

        webSocketProcessor.close(webSocket, 1000);
    }

    @Override
    public void onError(WebSocketConnection webSocketConnection, Throwable throwable) {
        WebSocket webSocket = (WebSocket) webSocketConnection.getWebSocketContext().getServletContext().getAttribute(webSocketConnection.toString());
        webSocketConnection.getWebSocketContext().getServletContext().removeAttribute(webSocketConnection.toString());

        webSocketProcessor.notifyListener(webSocket, new WebSocketEventListener.WebSocketEvent<Throwable>(throwable, WebSocketEventListener.WebSocketEvent.TYPE.EXCEPTION, webSocket));
    }
View Full Code Here

        webSocketProcessor.notifyListener(webSocket, new WebSocketEventListener.WebSocketEvent<Throwable>(throwable, WebSocketEventListener.WebSocketEvent.TYPE.EXCEPTION, webSocket));
    }

    @Override
    public void onClose(WebSocketConnection webSocketConnection, ClosingMessage closingMessage) {
        WebSocket webSocket = (WebSocket) webSocketConnection.getWebSocketContext().getServletContext().getAttribute(webSocketConnection.toString());
        webSocketConnection.getWebSocketContext().getServletContext().removeAttribute(webSocketConnection.toString());

        webSocketProcessor.close(webSocket, closingMessage.getStatusCode());
    }
View Full Code Here

    }

    @Test
    public void basicWorkflow() throws IOException, ServletException, ExecutionException, InterruptedException {
        ByteArrayOutputStream b = new ByteArrayOutputStream();
        final WebSocket w = new ArrayBaseWebSocket(b);
        final WebSocketProcessor processor = WebSocketProcessorFactory.getDefault()
                .getWebSocketProcessor(framework);
        registerWebSocketHandler("/*", new EchoHandler());

        AtmosphereRequest request = new AtmosphereRequest.Builder().destroyable(false).body("yoComet").pathInfo("/a").build();
View Full Code Here

TOP

Related Classes of org.atmosphere.websocket.WebSocket

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.