Package io.netty.handler.codec.http.websocketx

Examples of io.netty.handler.codec.http.websocketx.TextWebSocketFrame.text()


            final String channelId = UUID.randomUUID().toString();
            final String register = JsonUtil.toJson(new RegisterMessageImpl(channelId));
            final ChannelFuture registerFuture = ch.writeAndFlush(new TextWebSocketFrame(register));
            registerFuture.sync();
            final TextWebSocketFrame registerFrame = handler.getTextFrame();
            final RegisterResponseImpl registerResponse = JsonUtil.fromJson(registerFrame.text(), RegisterResponseImpl.class);
            assertThat(registerResponse.getMessageType(), equalTo(MessageType.Type.REGISTER));
            assertThat(registerResponse.getChannelId(), equalTo(channelId));

            ch.writeAndFlush(new CloseWebSocketFrame());
View Full Code Here


            final String uaid = UUIDUtil.newUAID();
            final String json = JsonUtil.toJson(new HelloMessageImpl(uaid.toString()));
            final ChannelFuture future = ch.writeAndFlush(new TextWebSocketFrame(json));
            future.sync();
            final TextWebSocketFrame textFrame = handler.getTextFrame();
            final HelloResponse fromJson = JsonUtil.fromJson(textFrame.text(), HelloResponseImpl.class);
            assertThat(fromJson.getMessageType(), equalTo(MessageType.Type.HELLO));
            assertThat(fromJson.getUAID(), equalTo(uaid));
            textFrame.release();

            Thread.sleep(3000);
View Full Code Here

    }

    private <T> T responseToType(final Object response, Class<T> type) {
        if (response instanceof TextWebSocketFrame) {
            final TextWebSocketFrame frame = (TextWebSocketFrame) response;
            String content = frame.text();
            if (content.startsWith("a[")) {
                content = TestUtil.extractJsonFromSockJSMessage(content);
            }
            return JsonUtil.fromJson(content, type);
        }
View Full Code Here

        }

        WebSocketFrame frame = (WebSocketFrame) msg;
        if (frame instanceof TextWebSocketFrame) {
            TextWebSocketFrame textFrame = (TextWebSocketFrame) frame;
            System.out.println("WebSocket Client received message: " + textFrame.text());
            if (!textFrame.text().equals("MESSAGE #" + receivedMessages)) {
                throw new AssertionError("Received: " + textFrame.text() + " expected: MESSAGE #" + receivedMessages);
            }
            receivedMessages++;
        } else if (frame instanceof BinaryWebSocketFrame) {
View Full Code Here

        WebSocketFrame frame = (WebSocketFrame) msg;
        if (frame instanceof TextWebSocketFrame) {
            TextWebSocketFrame textFrame = (TextWebSocketFrame) frame;
            System.out.println("WebSocket Client received message: " + textFrame.text());
            if (!textFrame.text().equals("MESSAGE #" + receivedMessages)) {
                throw new AssertionError("Received: " + textFrame.text() + " expected: MESSAGE #" + receivedMessages);
            }
            receivedMessages++;
        } else if (frame instanceof BinaryWebSocketFrame) {
            BinaryWebSocketFrame binaryFrame = (BinaryWebSocketFrame) frame;
View Full Code Here

        WebSocketFrame frame = (WebSocketFrame) msg;
        if (frame instanceof TextWebSocketFrame) {
            TextWebSocketFrame textFrame = (TextWebSocketFrame) frame;
            System.out.println("WebSocket Client received message: " + textFrame.text());
            if (!textFrame.text().equals("MESSAGE #" + receivedMessages)) {
                throw new AssertionError("Received: " + textFrame.text() + " expected: MESSAGE #" + receivedMessages);
            }
            receivedMessages++;
        } else if (frame instanceof BinaryWebSocketFrame) {
            BinaryWebSocketFrame binaryFrame = (BinaryWebSocketFrame) frame;
            ByteBuffer bytes = binaryFrame.content().nioBuffer();
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.