Package io.netty.buffer

Examples of io.netty.buffer.ByteBuf.writeBytes()


            outBuffer.writeBytes(ID_PREFIX_AS_BYTES)
                     .writeBytes(serverSentEvent.getEventId().getBytes())
                     .writeBytes(NEW_LINE_AS_BYTES);
        }

        outBuffer.writeBytes(NEW_LINE_AS_BYTES);
    }

    private static void appendData(ServerSentEvent serverSentEvent, ByteBuf outBuffer) {
        if (serverSentEvent.isSplitMode()) {
            for (String dataLine : PATTERN_NEW_LINE.split(serverSentEvent.getEventData())) {
View Full Code Here


    }

    @Override
    public void writeBytes(byte[] msg) {
        ByteBuf data = getChannel().alloc().buffer(msg.length);
        data.writeBytes(msg);
        writeOnChannel(new DatagramPacket(data, receiverAddress));
    }

    @Override
    public Observable<Void> writeBytesAndFlush(byte[] msg) {
View Full Code Here

        encode(type, tmp, value, context);

        byte[] bytes = tmp.toString().getBytes(context.getCharset());

        channelBuffer.writeInt(bytes.length);
        channelBuffer.writeBytes(bytes);
      }

    }
    else {
View Full Code Here

        out.writeInt(reply.getStartingFrom());
        final List<BSONObject> documents = reply.getDocuments();
        out.writeInt(documents.size());

        for (final BSONObject bsonObject : documents) {
            out.writeBytes(BSON.encode(bsonObject));
        }

        log.debug("wrote reply: {}", reply);

        // now set the length
View Full Code Here

    @Test
    public void testDecodeStringUnicode() throws Exception {
        String string = "\u0442\u0435\u0441\u0442";
        byte[] bytes = string.getBytes("UTF-8");
        ByteBuf buffer = Unpooled.buffer();
        buffer.writeBytes(bytes);
        buffer.writeByte(0);
        assertThat(new BsonDecoder().decodeCString(buffer)).isEqualTo(string);
    }

    @Test
View Full Code Here

   
    private void sendMessage(ChannelHandlerContext ctx, String config) {
      byte[] bytes = config.getBytes(charset);
      ByteBuf message = Unpooled.buffer(4 + bytes.length);
        message.writeInt(bytes.length);
        message.writeBytes(bytes);
        ctx.writeAndFlush(message);
  }
   
    public static class ClientInfo {
      private String address;
View Full Code Here

        // Do not encrypt the first write request if this handler is
        // created with startTLS flag turned on.
        if (!internal && startTls && !sentFirstMessage) {
            sentFirstMessage = true;
            out.writeBytes(in);
            ctx.flush(promise);
            return;
        }

        if (ctx.executor() == ctx.channel().eventLoop()) {
View Full Code Here

    }

    @Override
    public void inboundBufferUpdated(ChannelHandlerContext ctx, ByteBuf in) throws Exception {
        ByteBuf out = relayChannel.outboundByteBuffer();
        out.writeBytes(in);
        if (relayChannel.isActive()) {
            relayChannel.flush();
        }
    }
View Full Code Here

    private void generateTraffic() {
        // Fill the outbound buffer up to 64KiB
        ByteBuf out = ctx.nextOutboundByteBuffer();
        while (out.readableBytes() < 65536) {
            out.writeBytes(content, 0, content.readableBytes());
        }

        // Flush the outbound buffer to the socket.
        // Once flushed, generate the same amount of traffic again.
        ctx.flush().addListener(trafficGenerator);
View Full Code Here

    }

    @Override
    public void inboundBufferUpdated(final ChannelHandlerContext ctx, ByteBuf in) throws Exception {
        ByteBuf out = inboundChannel.outboundByteBuffer();
        out.writeBytes(in);
        inboundChannel.flush().addListener(new ChannelFutureListener() {
            @Override
            public void operationComplete(ChannelFuture future) throws Exception {
                if (future.isSuccess()) {
                    ctx.channel().read();
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.