Examples of CloseWebSocketFrame


Examples of io.netty.handler.codec.http.websocketx.CloseWebSocketFrame

    public void write(String data){
        context.channel().write(new TextWebSocketFrame(data));
    }

    public void close(){
        context.channel().write(new CloseWebSocketFrame());
    }
View Full Code Here

Examples of io.netty.handler.codec.http.websocketx.CloseWebSocketFrame

            logger.debug("Returned {} connection to {} but an error occurred - {}", this, pool, ce.getMessage());
        }
    }

    private void shutdown(final CompletableFuture<Void> future) {
        channel.writeAndFlush(new CloseWebSocketFrame());
        final ChannelPromise promise = channel.newPromise();
        promise.addListener(f -> {
            if (f.cause() != null)
                future.completeExceptionally(f.cause());
            else
View Full Code Here

Examples of io.netty.handler.codec.http.websocketx.CloseWebSocketFrame

            while (true) {
                String msg = console.readLine();
                if (msg == null) {
                    break;
                } else if ("bye".equals(msg.toLowerCase())) {
                    ch.writeAndFlush(new CloseWebSocketFrame());
                    ch.closeFuture().sync();
                    break;
                } else if ("ping".equals(msg.toLowerCase())) {
                    WebSocketFrame frame = new PingWebSocketFrame(Unpooled.wrappedBuffer(new byte[] { 8, 1, 8, 1 }));
                    ch.writeAndFlush(frame);
View Full Code Here

Examples of io.netty.handler.codec.http.websocketx.CloseWebSocketFrame

        // as we have a HttpEncoder in the pipeline to start with.
        ch.readOutbound();

        assertThat(((TextWebSocketFrame) readOutboundDiscardEmpty(ch)).content().toString(UTF_8), equalTo("o"));

        ch.writeInbound(new CloseWebSocketFrame(1000, "Normal close"));
        final CloseWebSocketFrame closeFrame = ch.readOutbound();
        assertThat(closeFrame.statusCode(), is(1000));
        assertThat(closeFrame.reasonText(), equalTo("Normal close"));
        verify(sockJsService).onOpen(any(SockJsSessionContext.class));
        verify(sockJsService).onClose();
    }
View Full Code Here

Examples of io.netty.handler.codec.http.websocketx.CloseWebSocketFrame

            System.out.println("WebSocket Client sending ping");
            ch.write(new PingWebSocketFrame(Unpooled.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.closeFuture().sync();
        } finally {
View Full Code Here

Examples of io.netty.handler.codec.http.websocketx.CloseWebSocketFrame

    }

    @Test
    public void testConnectionClose() throws Exception {
        TestSequenceExecutor executor = new TestSequenceExecutor()
                .withClientFrames(new CloseWebSocketFrame(1000, "close"))
                .withExpectedOnServer(1)
                .withServerFrames(new CloseWebSocketFrame(1001, "close requested"))
                .withExpectedOnClient(1)
                .execute();

        assertTrue("Expected close on server", executor.getReceivedClientFrames().get(0) instanceof CloseWebSocketFrame);
        assertTrue("Expected close on server", executor.getReceivedServerFrames().get(0) instanceof CloseWebSocketFrame);
View Full Code Here

Examples of io.netty.handler.codec.http.websocketx.CloseWebSocketFrame

            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

Examples of io.netty.handler.codec.http.websocketx.CloseWebSocketFrame

            while (true) {
                String msg = console.readLine();
                if (msg == null) {
                    break;
                } else if ("bye".equals(msg.toLowerCase())) {
                    ch.writeAndFlush(new CloseWebSocketFrame());
                    ch.closeFuture().sync();
                    break;
                } else if ("ping".equals(msg.toLowerCase())) {
                    WebSocketFrame frame = new PingWebSocketFrame(Unpooled.wrappedBuffer(new byte[] { 8, 1, 8, 1 }));
                    ch.writeAndFlush(frame);
View Full Code Here

Examples of io.netty.handler.codec.http.websocketx.CloseWebSocketFrame

      super.close();
    } else {
      // make sure everything is flushed out on close
      endReadAndFlush();
      // close the websocket connection by sending a close frame.
      handshaker.close(channel, new CloseWebSocketFrame(1000, null));
    }
  }
View Full Code Here

Examples of io.netty.handler.codec.http.websocketx.CloseWebSocketFrame

          break;
        case TEXT:
          msg = new TextWebSocketFrame(frame.isFinal(), 0, buf);
          break;
        case CLOSE:
          msg = new CloseWebSocketFrame(true, 0, buf);
          break;
        case CONTINUATION:
          msg = new ContinuationWebSocketFrame(frame.isFinal(), 0, buf);
          break;
        case PONG:
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.