Package org.jboss.netty.handler.codec.http.websocketx

Examples of org.jboss.netty.handler.codec.http.websocketx.CloseWebSocketFrame


    }

    public void destroy() {
        isShutdown.set(true);
        httpChannels.close();
        websocketChannels.write(new CloseWebSocketFrame());

        if (framework != null) framework.destroy();
        suspendTimer.shutdown();
    }
View Full Code Here


     */
    @Override
    public void close() {
        AtmosphereResourceImpl impl = AtmosphereResourceImpl.class.cast(resource());
        if (impl != null) {
            channel.write(new CloseWebSocketFrame()).addListener(ChannelFutureListener.CLOSE);
        }
    }
View Full Code Here

        builder.addEndpoint(ServerEndpointConfig.Builder.create(TestEndPoint.class, "/").configurator(new InstanceConfigurator(new TestEndPoint())).build());
        deployServlet(builder);

        WebSocketTestClient client = new WebSocketTestClient(getVersion(), new URI("ws://" + DefaultServer.getHostAddress("default") + ":" + DefaultServer.getHostPort("default") + "/"));
        client.connect();
        client.send(new CloseWebSocketFrame(code, reasonText), new FrameChecker(CloseWebSocketFrame.class, payload.array(), latch));
        latch.getIoFuture().get();
        clientLatch.await();
        Assert.assertEquals(code, reason.get().getCloseCode().getCode());
        Assert.assertEquals(reasonText, reason.get().getReasonPhrase());
        Assert.assertEquals(1, closeCount.get());
View Full Code Here

        builder.addEndpoint(ServerEndpointConfig.Builder.create(TestEndPoint.class, "/").configurator(new InstanceConfigurator(new TestEndPoint())).build());
        deployServlet(builder);

        WebSocketTestClient client = new WebSocketTestClient(getVersion(), new URI("ws://" + DefaultServer.getHostAddress("default") + ":" + DefaultServer.getHostPort("default") + "/"));
        client.connect();
        client.send(new CloseWebSocketFrame(code, null), new FrameChecker(CloseWebSocketFrame.class, payload.array(), latch));
        if(latch.getIoFuture().await(10, TimeUnit.SECONDS) != IoFuture.Status.DONE) {
            Assert.fail();
        }
        latch.getIoFuture().get();
        clientLatch.await();
View Full Code Here

        final AtomicBoolean receivedResponse = new AtomicBoolean(false);

        final FutureResult latch = new FutureResult();
        WebSocketTestClient client = new WebSocketTestClient(getVersion(), new URI("ws://" + NetworkUtils.formatPossibleIpv6Address(DefaultServer.getHostAddress("default")) + ":" + DefaultServer.getHostPort("default") + "/"));
        client.connect();
        client.send(new CloseWebSocketFrame(), new FrameChecker(CloseWebSocketFrame.class, new byte[0], latch));
        latch.getIoFuture().get();
        Assert.assertFalse(receivedResponse.get());
        client.destroy();
    }
View Full Code Here

     * Destroy the client and also close open connections if any exist
     */
    public void destroy() {
        if (!closed) {
            final CountDownLatch latch = new CountDownLatch(1);
            send(new CloseWebSocketFrame(), new FrameListener() {
                @Override
                public void onFrame(WebSocketFrame frame) {
                    latch.countDown();
                }

View Full Code Here

            System.out.println("WebSocket Client sending ping");
            ch.write(new PingWebSocketFrame(ChannelBuffers.copiedBuffer(new byte[]{1, 2, 3, 4, 5, 6})));

            // Close
            System.out.println("WebSocket Client sending close");
            ch.write(new CloseWebSocketFrame());

            // WebSocketClientHandler will close the connection when the server
            // responds to the CloseWebSocketFrame.
            ch.getCloseFuture().awaitUninterruptibly();
        } finally {
View Full Code Here

                            logger.info("frame received: " + frame);
                        }
                    });
            client.connect().await(1000, TimeUnit.MILLISECONDS);           
            Thread.sleep(1000);
            client.send(new CloseWebSocketFrame());
            Thread.sleep(1000);
            client.disconnect();
           
            clientFactory.shutdown();
           
View Full Code Here

           
            // wait for publish/subscribe
            Thread.sleep(1000);
           
            // close first client
            publishingClient.send(new CloseWebSocketFrame());
            publishingClient.disconnect();

            // close second client
            subscribingClient.send(new CloseWebSocketFrame());
            subscribingClient.disconnect();
           
            Thread.sleep(1000);
           
            clientFactory.shutdown();
View Full Code Here

                            logger.error(t.getMessage(), t);
                        }
                    });
            client.connect().await(1000, TimeUnit.MILLISECONDS);           
            Thread.sleep(1000);
            client.send(new CloseWebSocketFrame());
            Thread.sleep(1000);
            client.disconnect();
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
        }
View Full Code Here

TOP

Related Classes of org.jboss.netty.handler.codec.http.websocketx.CloseWebSocketFrame

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.