本文整理汇总了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;
}
示例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);
}
示例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());
}
}
示例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);
}
示例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);
}
示例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));
}
示例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);
}
示例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 );
}
示例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]);
}
}
}
示例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);
}
示例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;
}
示例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);
}
示例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());
}
示例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();
}
示例15: write
import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
@Override
public void write(ByteBuf buf) {
buf.writeLong(value);
}