當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。