Package org.jboss.aerogear.io.netty.handler.codec.sockjs.protocol

Examples of org.jboss.aerogear.io.netty.handler.codec.sockjs.protocol.MessageFrame


            final List<String> allMessages = getSockJsSession().getAllMessages();
            if (allMessages.isEmpty()) {
                return;
            }

            final MessageFrame messageFrame = new MessageFrame(allMessages);
            logger.debug("flushing [{}]", messageFrame);
            channel.writeAndFlush(messageFrame).addListener(new ChannelFutureListener() {
                @Override
                public void operationComplete(final ChannelFuture future) throws Exception {
                    if (!future.isSuccess()) {
View Full Code Here


    private void flushMessages(final ChannelHandlerContext ctx) {
        final List<String> allMessages = getSockJsSession().getAllMessages();
        if (allMessages.isEmpty()) {
            return;
        }
        final MessageFrame messageFrame = new MessageFrame(allMessages);
        ctx.channel().writeAndFlush(messageFrame).addListener(new ChannelFutureListener() {
            @Override
            public void operationComplete(final ChannelFuture future) throws Exception {
                if (!future.isSuccess()) {
                    final SockJsSession sockJsSession = getSockJsSession();
View Full Code Here

        @Override
        public void send(String message) {
            final Channel channel = sessionState.getSendingContext().channel();
            if (isWritable(channel)) {
                channel.writeAndFlush(new MessageFrame(message));
            } else {
                sessionState.storeMessage(message);
            }
        }
View Full Code Here

    public void write(final ChannelHandlerContext ctx, final Object msg, final ChannelPromise promise)
            throws Exception {
        if (msg instanceof Frame) {
            final Frame sockJSFrame = (Frame) msg;
            if (sockJSFrame instanceof MessageFrame) {
                final MessageFrame messageFrame = (MessageFrame) sockJSFrame;
                final List<String> messages = messageFrame.messages();
                for (String message : messages) {
                    ctx.write(new TextWebSocketFrame(message));
                }
            }
        }
View Full Code Here

        final String header = headerChunk.content().toString(UTF_8);
        assertThat(header, containsString("var c = parent.callback"));
        final HttpContent chunk = ch.readOutbound();
        assertThat(chunk.content().toString(UTF_8), equalTo("<script>\np(\"o\");\n</script>\r\n"));

        ch.write(new MessageFrame("x"));
        final HttpContent messageContent = ch.readOutbound();
        assertThat(messageContent.content().toString(UTF_8), equalTo("<script>\np(\"a[\\\"x\\\"]\");\n</script>\r\n"));
    }
View Full Code Here

public class WebSocketSendHandlerTest {

    @Test
    public void messageReceived() throws Exception {
        final EmbeddedChannel ch = createWebsocketChannel(SockJsConfig.withPrefix("/echo").build());
        ch.writeOutbound(new MessageFrame("testing"));
        final TextWebSocketFrame textFrame = ch.readOutbound();
        assertThat(textFrame.content().toString(CharsetUtil.UTF_8), equalTo("a[\"testing\"]"));
        textFrame.release();
    }
View Full Code Here

public class JsonpPollingTransportTest {

    @Test
    public void flushMessageFrame() {
        final FullHttpResponse response = writeFrame(new MessageFrame("a"));
        assertThat(response.getStatus(), equalTo(HttpResponseStatus.OK));
        SockJsTestUtil.verifyNoCacheHeaders(response);
        assertThat(response.content().toString(CharsetUtil.UTF_8), equalTo("callback(\"a[\\\"a\\\"]\");\r\n"));
    }
View Full Code Here

public class MessageFrameTest {

    @Test
    public void messages() {
        final String[] messages = {"one", "two", "three"};
        final MessageFrame messageFrame = new MessageFrame(messages);
        assertThat(messageFrame.messages().size(), CoreMatchers.is(3));
        assertThat(messageFrame.messages(), CoreMatchers.hasItems("one", "two", "three"));
        messageFrame.release();
    }
View Full Code Here

    }

    @Test
    public void createWithNullTerminatedArray() {
        final String[] nullTerminated = {"one", "two", null, "three"};
        final MessageFrame messageFrame = new MessageFrame(nullTerminated);
        assertThat(messageFrame.messages().size(), CoreMatchers.is(2));
        assertThat(messageFrame.messages(), CoreMatchers.hasItems("one", "two"));
        messageFrame.release();
    }
View Full Code Here

public class FramesTest {

    @Test
    public void copy() {
        assertCopy(new MessageFrame("testing copy"));
        assertCopy(new CloseFrame(100, "msg"));
        assertCopy(new HeartbeatFrame());
        assertCopy(new OpenFrame());
        assertCopy(new PreludeFrame());
    }
View Full Code Here

TOP

Related Classes of org.jboss.aerogear.io.netty.handler.codec.sockjs.protocol.MessageFrame

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.