Examples of StringWriteChannelListener


Examples of io.undertow.util.StringWriteChannelListener

    }

    private void sendBadRequestAndClose(final StreamConnection connection, final Exception exception) {
        UndertowLogger.REQUEST_IO_LOGGER.failedToParseRequest(exception);
        connection.getSourceChannel().suspendReads();
        new StringWriteChannelListener(BAD_REQUEST) {
            @Override
            protected void writeDone(final StreamSinkChannel c) {
                super.writeDone(c);
                c.suspendWrites();
                IoUtils.safeClose(connection);
View Full Code Here

Examples of io.undertow.util.StringWriteChannelListener

                }

                request.getReadSetter().set(ChannelListeners.drainListener(Long.MAX_VALUE, new ChannelListener<Channel>() {
                            @Override
                            public void handleEvent(final Channel channel) {
                                new StringWriteChannelListener("COMPLETED") {
                                    @Override
                                    protected void writeDone(final StreamSinkChannel channel) {
                                        exchange.endExchange();
                                    }
                                }.setup(response);
View Full Code Here

Examples of io.undertow.util.StringWriteChannelListener

                            new StringReadChannelListener(exchange.getBufferPool()) {
                                @Override
                                protected void stringDone(final String string) {
                                    try {
                                        if (string.equals("hello")) {
                                            new StringWriteChannelListener("world")
                                                    .setup(channel.send(WebSocketFrameType.TEXT, "world".length()));
                                        } else {
                                            new StringWriteChannelListener(string)
                                                    .setup(channel.send(WebSocketFrameType.TEXT, string.length()));
                                        }
                                    } catch (IOException e) {
                                        e.printStackTrace();
                                        throw new RuntimeException(e);
                                    }
                                }

                                @Override
                                protected void error(final IOException e) {
                                    try {
                                        e.printStackTrace();
                                        new StringWriteChannelListener("ERROR")
                                                .setup(channel.send(WebSocketFrameType.TEXT, "ERROR".length()));
                                    } catch (IOException ex) {
                                        ex.printStackTrace();
                                        throw new RuntimeException(ex);
                                    }
View Full Code Here

Examples of io.undertow.util.StringWriteChannelListener

                        final OutputStream outputStream = exchange.getOutputStream();
                        outputStream.write("Connection not persistent".getBytes());
                        outputStream.close();
                        return;
                    }
                    new StringWriteChannelListener(message).setup(exchange.getResponseChannel());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
        });
View Full Code Here

Examples of io.undertow.util.StringWriteChannelListener

        });
        webSocketChannel.resumeReceives();


        StreamSinkFrameChannel sendChannel = webSocketChannel.send(WebSocketFrameType.TEXT, 11);
        new StringWriteChannelListener("Hello World").setup(sendChannel);

        latch.await(10, TimeUnit.SECONDS);
        Assert.assertEquals("Hello World", result.get());
        webSocketChannel.sendClose();
    }
View Full Code Here

Examples of io.undertow.util.StringWriteChannelListener

                        outputStream.close();
                        return;
                    }
                    exchange.getResponseHeaders().put(Headers.TRANSFER_ENCODING, Headers.CHUNKED.toString());
                    exchange.putAttachment(HttpAttachments.PRE_CHUNKED_RESPONSE, true);
                    new StringWriteChannelListener(chunkedMessage).setup(exchange.getResponseChannel());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
        });
View Full Code Here

Examples of io.undertow.util.StringWriteChannelListener

                    }
                    HeaderMap trailers = new HeaderMap();
                    exchange.putAttachment(HttpAttachments.RESPONSE_TRAILERS, trailers);
                    trailers.put(HttpString.tryFromString("foo"), "fooVal");
                    trailers.put(HttpString.tryFromString("bar"), "barVal");
                    new StringWriteChannelListener(message).setup(exchange.getResponseChannel());

                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
View Full Code Here

Examples of io.undertow.util.StringWriteChannelListener

    }

    private void sendBadRequestAndClose(final StreamConnection channel, final Exception exception) {
        UndertowLogger.REQUEST_IO_LOGGER.failedToParseRequest(exception);
        channel.getSourceChannel().suspendReads();
        new StringWriteChannelListener(BAD_REQUEST) {
            @Override
            protected void writeDone(final StreamSinkChannel c) {
                IoUtils.safeClose(channel);
            }
        }.setup(channel.getSinkChannel());
View Full Code Here

Examples of io.undertow.util.StringWriteChannelListener

    }

    private void sendBadRequestAndClose(final StreamConnection channel, final Exception exception) {
        UndertowLogger.REQUEST_IO_LOGGER.failedToParseRequest(exception);
        channel.getSourceChannel().suspendReads();
        new StringWriteChannelListener(BAD_REQUEST) {
            @Override
            protected void writeDone(final StreamSinkChannel c) {
                IoUtils.safeClose(channel);
            }
        }.setup(channel.getSinkChannel());
View Full Code Here

Examples of io.undertow.util.StringWriteChannelListener

    }

    private void sendBadRequestAndClose(final StreamConnection channel, final Exception exception) {
        UndertowLogger.REQUEST_IO_LOGGER.failedToParseRequest(exception);
        channel.getSourceChannel().suspendReads();
        new StringWriteChannelListener(BAD_REQUEST) {
            @Override
            protected void writeDone(final StreamSinkChannel c) {
                IoUtils.safeClose(channel);
            }
        }.setup(channel.getSinkChannel());
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.