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


Java ByteBuf.writeLong方法代码示例

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


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

示例1: encode

import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
@Override
public List<Object> encode(ByteBufAllocator alloc) {
    ByteBuf meta = metadata(alloc);

    ByteBuf head = alloc.buffer(FastdfsConstants.FDFS_HEAD_LEN);
    head.writeLong(meta.readableBytes() + size);
    head.writeByte(cmd());
    head.writeByte(FastdfsConstants.ERRNO_OK);

    CompositeByteBuf cbb = alloc.compositeBuffer();
    cbb.addComponents(head, meta);
    cbb.writerIndex(head.readableBytes() + meta.readableBytes());

    List<Object> requests = new LinkedList<>();
    requests.add(cbb);
    requests.add(content);
    return requests;
}
 
开发者ID:rodbate,项目名称:fastdfs-spring-boot,代码行数:19,代码来源:FileOperationEncoder.java

示例2: encode

import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
private static void encode(long statement, String query, int[] paramDataTypes, ByteBuf out) {
  int pos = out.writerIndex();
  out.writeByte(PARSE);
  out.writeInt(0);
  if(statement == 0) {
    out.writeByte(0);
  } else {
    out.writeLong(statement);
  }
  Util.writeCStringUTF8(out, query);
  // no parameter data types (OIDs)
  if(paramDataTypes == null) {
    out.writeShort(0);
  } else {
    // Parameter data types (OIDs)
    out.writeShort(paramDataTypes.length);
    for (int paramDataType : paramDataTypes) {
      out.writeInt(paramDataType);
    }
  }
  out.setInt(pos + 1, out.writerIndex() - pos - 1);
}
 
开发者ID:vietj,项目名称:reactive-pg-client,代码行数:23,代码来源:Parse.java

示例3: toBytes

import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
@Override
public void toBytes(ByteBuf buf) {
	buf.writeInt(x);
	buf.writeInt(y);
	buf.writeInt(z);

	buf.writeInt(players.size());

	buf.writeBoolean(isGameLive);

	for (UUID player : players) {
		buf.writeLong(player.getMostSignificantBits());
		buf.writeLong(player.getLeastSignificantBits());
	}

	buf.writeBoolean(lobbyHost != null);

	if (lobbyHost != null) {
		buf.writeLong(lobbyHost.getMostSignificantBits());
		buf.writeLong(lobbyHost.getLeastSignificantBits());
	}
}
 
开发者ID:TominoCZ,项目名称:PAYDAY,代码行数:23,代码来源:PacketSyncTileEntityClient.java

示例4: encode

import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
@Override
protected void encode(ChannelHandlerContext channelHandlerContext, RpcMessage message, ByteBuf byteBuf) throws Exception {
    Header header = message.getHeader();
    byteBuf.writeShort(header.getMagic());
    byteBuf.writeByte(header.getVersion());
    byteBuf.writeByte(header.getExtend());
    byteBuf.writeLong(header.getMessageID());
    Object content = message.getContent();
    // 心跳消息,没有body
    if (content == null && EventType.typeofHeartBeat(header.getExtend())) {
        byteBuf.writeInt(0);
        return;
    }
    Serialization serialization = SerializeType.getSerializationByExtend(header.getExtend());
    Compress compress = CompressType.getCompressTypeByValueByExtend(header.getExtend());
    byte[] payload = compress.compress(serialization.serialize(content));
    byteBuf.writeInt(payload.length);
    byteBuf.writeBytes(payload);
}
 
开发者ID:chenxh,项目名称:rpc,代码行数:20,代码来源:NettyEncoder.java

示例5: toBytes

import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
@Override
public void toBytes(ByteBuf buf) {
    
    buf.writeInt(this.x);
    buf.writeInt(this.y);
    buf.writeInt(this.z);
    
    buf.writeLong(energy);

    NBTTagList list = new NBTTagList();
    for(AccumulatorInfo info : this.infos) {
        list.appendTag(info.writeToNBT());
    }
    NBTTagCompound tag = new NBTTagCompound();
    tag.setTag("infos", list);
    ByteBufUtils.writeTag(buf, tag);
}
 
开发者ID:jaredlll08,项目名称:Machines-and-Stuff,代码行数:18,代码来源:MessageAccumulator.java

示例6: writePayload

import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
@Override
public void writePayload(ByteBuf buf) {
    buf.writeShort(classId);
    buf.writeShort(0); // Write 0 for weight
    buf.writeLong(bodySize);

    int propertyFlags = getPropertyFlagsValue(properties.getValue(PROPERTY_FLAGS));

    buf.writeShort(propertyFlags);
    writeProperty(buf, properties.getValue(Metadata.CONTENT_TYPE));
    writeProperty(buf, properties.getValue(Metadata.CONTENT_ENCODING));
    writeFieldTable(buf, headers);
    writeProperty(buf, properties.getValue(Metadata.DELIVERY_MODE));
    writeProperty(buf, properties.getValue(Metadata.PRIORITY));
    writeProperty(buf, properties.getValue(Metadata.CORRELATION_ID));
    writeProperty(buf, properties.getValue(REPLY_TO));
    writeProperty(buf, properties.getValue(Metadata.EXPIRATION));
    writeProperty(buf, properties.getValue(Metadata.MESSAGE_ID));
    writeProperty(buf, properties.getValue(TIMESTAMP));
    writeProperty(buf, properties.getValue(TYPE));
    writeProperty(buf, properties.getValue(USER_ID));
    writeProperty(buf, properties.getValue(APPLICATION_ID));
}
 
开发者ID:wso2,项目名称:message-broker,代码行数:24,代码来源:HeaderFrame.java

示例7: testDeserialize

import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
@Test
public void testDeserialize() throws Exception {
  ByteBuf buf = Unpooled.buffer(16);
  buf.writeInt(0);
  buf.writeInt(1);
  buf.writeLong(2);
  buf.writeLong(3);
  buf.writeInt(4);
  buf.writeInt(3);
  buf.writeInt(0);
  buf.writeDouble(-1.0);
  buf.writeInt(1);
  buf.writeDouble(-2.0);
  buf.writeInt(2);
  buf.writeDouble(-3.0);
  serverSparseDoubleRow.deserialize(buf);
  assertEquals(serverSparseDoubleRow.getRowId(), 0);
  assertEquals(serverSparseDoubleRow.getClock(), 1);
  assertEquals(serverSparseDoubleRow.getStartCol(), 2);
  assertEquals(serverSparseDoubleRow.getEndCol(), 3);
  assertEquals(serverSparseDoubleRow.getRowVersion(), 4);
  assertEquals(serverSparseDoubleRow.getData().size(), 3);
  assertEquals(serverSparseDoubleRow.getData().get(0), -1, 0.0);
  assertEquals(serverSparseDoubleRow.getData().get(1), -2, 0.0);
  assertEquals(serverSparseDoubleRow.getData().get(2), -3, 0.0);
}
 
开发者ID:Tencent,项目名称:angel,代码行数:27,代码来源:ServerSparseDoubleRowTest.java

示例8: write

import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
@Override
public void write( ByteBuf buf ) throws IOException {
    writeVarInt( entityId, buf );
    writeUUID( entityUUID, buf );
    writeString( title, buf );
    buf.writeLong( position.asLong() );
    buf.writeByte( direction );
}
 
开发者ID:lukas81298,项目名称:FlexMC,代码行数:9,代码来源:MessageS04SpawnPainting.java

示例9: serialize

import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
@Override
public void serialize(ByteBuf buf) {
  super.serialize(buf);
  buf.writeInt(rowId);
  buf.writeInt(index.length);

  if (index.length > 0) {
    for(int i = 0; i < index.length; i++) {
      buf.writeLong(index[i]);
    }
  }
}
 
开发者ID:Tencent,项目名称:angel,代码行数:13,代码来源:LongIndexPartGetParam.java

示例10: serialize

import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
@Override
public void serialize(ByteBuf buf) {
  buf.writeInt(rowId);
  buf.writeInt(clock);
  buf.writeLong(startCol);
  buf.writeLong(endCol);
  buf.writeInt(rowVersion);
}
 
开发者ID:Tencent,项目名称:angel,代码行数:9,代码来源:ServerRow.java

示例11: metadata

import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
@Override
protected ByteBuf metadata(ByteBufAllocator alloc) {
    byte[] pathBytes = fileId.pathBytes();
    int metaLen = 3 * FastdfsConstants.FDFS_PROTO_PKG_LEN_SIZE + pathBytes.length;
    ByteBuf buf = alloc.buffer(metaLen);
    buf.writeLong(pathBytes.length);
    buf.writeLong(offset);
    buf.writeLong(size());
    buf.writeBytes(pathBytes);
    return buf;
}
 
开发者ID:rodbate,项目名称:fastdfs-spring-boot,代码行数:12,代码来源:FileModifyEncoder.java

示例12: toBytes

import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
@Override
public void toBytes(ByteBuf buf) {
    byte[] encodedKey = this.plugin.getBytes(StandardCharsets.UTF_8);
    buf.writeInt(encodedKey.length);
    buf.writeBytes(encodedKey);
    buf.writeLong(this.seed);
}
 
开发者ID:Randores,项目名称:Randores2,代码行数:8,代码来源:RandoresUpdatePluginSeedRequest.java

示例13: toBytes

import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
@Override
public void toBytes(ByteBuf buf) {
	buf.writeBoolean(inLobby);
	buf.writeBoolean(ready);

	buf.writeLong(playerProfileUUID.getMostSignificantBits());
	buf.writeLong(playerProfileUUID.getLeastSignificantBits());
}
 
开发者ID:TominoCZ,项目名称:PAYDAY,代码行数:9,代码来源:PacketSyncPlayerPropertiesClient.java

示例14: sendTransmissionSimpleReply

import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
private void sendTransmissionSimpleReply(ChannelHandlerContext ctx, int error, long handle, ByteBuf data) {
    synchronized (this) {
        ByteBuf bbr = ctx.alloc().buffer(16);
        bbr.writeInt(Protocol.REPLY_MAGIC);
        bbr.writeInt(error); // zero for okay
        bbr.writeLong(handle);
        ctx.write(bbr);
        if (data != null) {
            ctx.write(data);
        }
    }
    ctx.flush();
    logPendingOperations();
}
 
开发者ID:MineboxOS,项目名称:minebox,代码行数:15,代码来源:TransmissionPhase.java

示例15: write

import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
@Override
public void write(ByteBuf buf) {
    buf.writeLong(value);
}
 
开发者ID:wso2,项目名称:message-broker,代码行数:5,代码来源:LongLongInt.java


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