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


Java ByteBuf.writeMedium方法代码示例

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


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

示例1: encode

import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
@Override
protected void encode(ChannelHandlerContext context, ServerMessage message, ByteBuf out) throws Exception {
	message.encode(stream);

	header.id = message.id;
	header.decrypted = stream.getBuffer();
	stream.reset(true);
	crypto.encryptPacket(header);

	out.writeShort(message.id);
	out.writeMedium(header.payload.length);
	out.writeShort((short)5);

	out.writeBytes(header.payload);
}
 
开发者ID:Tarik02,项目名称:cr-private-server,代码行数:16,代码来源:PacketEncoder.java

示例2: shakeHands

import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
public void shakeHands(int revision) throws IOException {
    // 15 = JS5 header
    writer.write((byte) 15);
    writer.write(revision);

    writer.flush();

    int response = reader.readByte();

    if (response != HANDSHAKE_SUCCESS) {
        if (response == HANDSHAKE_OUTDATED) {
            throw new IllegalStateException("Handshake failed, wrong revision specified");
        }
        throw new IllegalStateException("Handshake failed, unknown error encountered");
    }

    ByteBuf buffer = Unpooled.buffer(4);
    // Login state
    // 2 = In-game
    // 3 = Not in-game
    buffer.writeByte(3);
    // Padding
    buffer.writeMedium(0);

    writer.write(buffer);
    writer.flush();
}
 
开发者ID:OSTracker,项目名称:ostracker,代码行数:28,代码来源:RemoteCache.java

示例3: downloadFile

import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
private FileResult downloadFile(int indexId, int fileId, boolean shouldDecompress)
        throws IOException {

    ByteBuf buffer = Unpooled.buffer(4);
    // Type
    buffer.writeByte(indexId == 255 ? 1 : 0);
    // Hash
    buffer.writeMedium(indexId << 16 | fileId);

    writer.write(buffer);
    writer.flush();

    int remoteIndexId = reader.readUnsignedByte();
    if (indexId != remoteIndexId) {
        throw new IllegalStateException("Remote index id "
                + remoteIndexId + " did not match input index id "
                + indexId);
    }

    int remoteFileId = reader.readUnsignedShort();
    if (fileId != remoteFileId) {
        throw new IllegalStateException("Remote file id "
                + remoteFileId + " did not match input file id "
                + fileId);
    }

    FileResult result = downloadCompressedFile(indexId, fileId);

    if (shouldDecompress) {
        result.decompress(null);
    }

    return result;
}
 
开发者ID:OSTracker,项目名称:ostracker,代码行数:35,代码来源:RemoteCache.java

示例4: toArray

import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
public int[] toArray ()
{
    final ByteBuf buf = Unpooled.buffer ( 4 );
    buf.writeMedium ( this.address );
    return new int[] { buf.getUnsignedByte ( 0 ), buf.getUnsignedByte ( 1 ), buf.getUnsignedByte ( 2 ) };
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:7,代码来源:InformationObjectAddress.java


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