当前位置: 首页>>代码示例>>Java>>正文


Java ByteBuf.writeBytes方法代码示例

本文整理汇总了Java中io.netty.buffer.ByteBuf.writeBytes方法的典型用法代码示例。如果您正苦于以下问题:Java ByteBuf.writeBytes方法的具体用法?Java ByteBuf.writeBytes怎么用?Java ByteBuf.writeBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.netty.buffer.ByteBuf的用法示例。


在下文中一共展示了ByteBuf.writeBytes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: toBytes

import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
@Override
public void toBytes(ByteBuf buf) {
	buf.writeInt(entityID);
	buf.writeByte(type);
	if (type == 0)
		buf.writeInt(intValue);
	else if (type == 1)
		buf.writeFloat(floatValue);
	else if (type == 2)
		buf.writeByte(byteValue);
	else if (type == 3) {
		byte[] stringValueArray = stringValue.getBytes(StandardCharsets.UTF_8);
		buf.writeByte(stringValueArray.length);
		buf.writeBytes(stringValueArray);
	}
	byte[] stringNameArray = name.getBytes(StandardCharsets.UTF_8);
	buf.writeBytes(stringNameArray);
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:19,代码来源:TF2Message.java

示例2: encode

import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
@Override
public void encode(ByteBuf out, Object message) throws IOException {
    try {
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        closer.register(byteArrayOutputStream);
        KryoSerialize kryoSerialization = new KryoSerialize(pool);
        kryoSerialization.serialize(byteArrayOutputStream, message);
        byte[] body = byteArrayOutputStream.toByteArray();
        int dataLength = body.length;
        out.writeInt(dataLength);
        out.writeBytes(body);
    } finally {
        closer.close();
    }
}
 
开发者ID:yu199195,项目名称:happylifeplat-transaction,代码行数:16,代码来源:KryoCodecServiceImpl.java

示例3: mirrorUnknown

import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
private ByteBuf mirrorUnknown ( final ByteBuf data, final byte typeId, final InformationStructure informationStructure, final byte size, final ASDUHeader header, final Cause newCause )
{
    logger.debug ( "Mirror unknown message -> {}", newCause );
    final ByteBuf reply = Unpooled.buffer ();

    EncodeHelper.encodeHeader ( typeId, informationStructure, this.options, (int)size, header.clone ( newCause ), reply );

    reply.writeBytes ( data ); // copy data

    return reply;
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:12,代码来源:MessageManager.java

示例4: channelActive

import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
/**
 *@description 客户端成功连接到服务器之后向服务器发送数据
 *@time 创建时间:2017年7月26日下午7:51:31
 *@param ctx
 *@throws Exception
 *@author dzn
 */
@Override
public void channelActive(ChannelHandlerContext ctx) throws Exception {
    ByteBuf message = null;
    for(int i = 0; i < 100; i ++){
        message = Unpooled.buffer(req.length);
        message.writeBytes(req);
        ctx.channel().writeAndFlush(message);
    }
}
 
开发者ID:SnailFastGo,项目名称:netty_op,代码行数:17,代码来源:RightTimeClientHandler.java

示例5: write

import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
@Override
public void write(byte[] bytes) {
	if(bytes!=null && bytes.length>0 && isActive())
	{
		ByteBuf buf=PooledByteBufAllocator.DEFAULT.buffer();
		buf.writeBytes(bytes);
		write(buf);
	}
}
 
开发者ID:juebanlin,项目名称:util4j,代码行数:10,代码来源:NettyConnection.java

示例6: writeInet

import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
public static void writeInet(InetSocketAddress inet, ByteBuf cb)
{
    byte[] address = inet.getAddress().getAddress();

    cb.writeByte(address.length);
    cb.writeBytes(address);
    cb.writeInt(inet.getPort());
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:9,代码来源:CBUtil.java

示例7: encode

import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
/**
 * 编码
 * 
 * @param out
 */
public void encode(ByteBuf out) {
	byte[] head = encodeHead();
	byte[] body = encodeBody();
	out.writeShort((short) (head.length + body.length + 2)); // 消息的总长度
	out.writeBytes(head); // 协议头
	out.writeShort((short) body.length); // 消息体长度
	out.writeBytes(body); // 消息体
}
 
开发者ID:inspingcc,项目名称:LibraSock,代码行数:14,代码来源:LibraMessage.java

示例8: writeBytes

import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
@Override
public void writeBytes(ByteBuffer bytes, ByteBuf dest) {
  if (bytes == null) {
    writeInt(-1, dest);
  } else {
    writeInt(bytes.remaining(), dest);
    dest.writeBytes(bytes.duplicate());
  }
}
 
开发者ID:datastax,项目名称:simulacron,代码行数:10,代码来源:ByteBufCodec.java

示例9: metadata

import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
@Override
protected ByteBuf metadata(ByteBufAllocator alloc) {
    byte[] pathBytes = fileId.pathBytes();

    int metaSize = 2 * FastdfsConstants.FDFS_PROTO_PKG_LEN_SIZE + pathBytes.length;
    ByteBuf buf = alloc.buffer(metaSize);
    buf.writeLong(pathBytes.length);
    buf.writeLong(size());
    buf.writeBytes(pathBytes);
    return buf;
}
 
开发者ID:rodbate,项目名称:fastdfs-spring-boot,代码行数:12,代码来源:FileAppendEncoder.java

示例10: shouldDeserializeTheMapCorrectly

import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
@Test
public void shouldDeserializeTheMapCorrectly() throws Exception {
    ByteBuf buf = new PooledByteBufAllocator(true).buffer();
    buf.writeBytes(new ObjectMapper().writeValueAsBytes(map));
    assertThat(mapCodec.getMapValueDecoder().decode(buf, new State(false)))
            .isInstanceOf(Map.class)
            .isEqualTo(map);
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:9,代码来源:JsonJacksonMapValueCodecTest.java

示例11: serialize

import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
@Override
public void serialize(ByteBuf buf) {
  super.serialize(buf);
  if (partResult != null) {
    byte[] data = partResult.getClass().getName().getBytes();
    buf.writeInt(data.length);
    buf.writeBytes(data);

    partResult.serialize(buf);
  }
}
 
开发者ID:Tencent,项目名称:angel,代码行数:12,代码来源:GetUDFResponse.java

示例12: encode

import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
public static void encode(ByteBuf buf, String s) {
  byte[] bytes = s.getBytes(StandardCharsets.UTF_8);
  buf.writeInt(bytes.length);
  buf.writeBytes(bytes);
}
 
开发者ID:spafka,项目名称:spark_deep,代码行数:6,代码来源:Encoders.java

示例13: main

import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
public static void main(String[] args) {
   	ByteBuf heapBuf = Unpooled.buffer(10);
   	heapBuf.writeBytes("helloworld".getBytes());
	heapBuffer(heapBuf);
}
 
开发者ID:zy416548283,项目名称:NettyStudy,代码行数:6,代码来源:ByteBufExamples.java

示例14: writeUUID

import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
public static void writeUUID(UUID uuid, ByteBuf cb)
{
    cb.writeBytes(UUIDGen.decompose(uuid));
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:5,代码来源:CBUtil.java

示例15: writeInetAddr

import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
@Override
public void writeInetAddr(InetAddress address, ByteBuf dest) {
  byte[] addr = address.getAddress();
  dest.writeByte(addr.length);
  dest.writeBytes(addr);
}
 
开发者ID:datastax,项目名称:simulacron,代码行数:7,代码来源:ByteBufCodec.java


注:本文中的io.netty.buffer.ByteBuf.writeBytes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。