Package org.xnio.channels

Examples of org.xnio.channels.BlockingWritableByteChannel


    private final WebSocketChannel channel;

    public TextWriter(WebSocketChannel channel, StreamSinkChannel sink) {
        this.sink = sink;
        this.channel = channel;
        ch = new BlockingWritableByteChannel(sink);
    }
View Full Code Here


    @Override
    public void sendText(ByteBuffer payload) throws IOException {
        checkBlockingAllowed();

        StreamSinkChannel sink = createSink(payload.remaining());
        BlockingWritableByteChannel channel = new BlockingWritableByteChannel(sink);
        while(payload.hasRemaining()) {
            channel.write(payload);
        }
        sink.shutdownWrites();
        channel.flush();
        channel.close();
    }
View Full Code Here

    public void sendText(ByteBuffer[] payload) throws IOException {
        checkBlockingAllowed();

        long length = StreamSinkChannelUtils.payloadLength(payload);
        StreamSinkChannel sink = createSink(length);
        BlockingWritableByteChannel channel = new BlockingWritableByteChannel(sink);
        long written = 0;
        while(written < length) {
            long w = channel.write(payload);
            if (w > 0) {
                written += w;
            }
        }
        sink.shutdownWrites();
        channel.flush();
        channel.close();
    }
View Full Code Here

    @Override
    public void sendText(ByteBuffer payload) throws IOException {
        checkBlockingAllowed();

        StreamSinkChannel sink = createSink(payload.remaining());
        BlockingWritableByteChannel channel = new BlockingWritableByteChannel(sink);
        while(payload.hasRemaining()) {
            channel.write(payload);
        }
        sink.shutdownWrites();
        channel.flush();
        channel.close();
    }
View Full Code Here

    public void sendText(ByteBuffer[] payload) throws IOException {
        checkBlockingAllowed();

        long length = StreamSinkChannelUtils.payloadLength(payload);
        StreamSinkChannel sink = createSink(length);
        BlockingWritableByteChannel channel = new BlockingWritableByteChannel(sink);
        long written = 0;
        while(written < length) {
            long w = channel.write(payload);
            if (w > 0) {
                written += w;
            }
        }
        sink.shutdownWrites();
        channel.flush();
        channel.close();
    }
View Full Code Here

TOP

Related Classes of org.xnio.channels.BlockingWritableByteChannel

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.