Package io.netty.buffer

Examples of io.netty.buffer.ByteBuf.writeShort()


    {
        int optLength = 2;
        for (Map.Entry<T, Object> entry : options.entrySet())
            optLength += 2 + entry.getKey().serializedValueSize(entry.getValue(), version);
        ByteBuf cb = Unpooled.buffer(optLength);
        cb.writeShort(options.size());
        for (Map.Entry<T, Object> entry : options.entrySet())
        {
            T opt = entry.getKey();
            cb.writeShort(opt.getId());
            opt.writeValue(entry.getValue(), cb, version);
View Full Code Here


        ByteBuf cb = Unpooled.buffer(optLength);
        cb.writeShort(options.size());
        for (Map.Entry<T, Object> entry : options.entrySet())
        {
            T opt = entry.getKey();
            cb.writeShort(opt.getId());
            opt.writeValue(entry.getValue(), cb, version);
        }
        return cb;
    }
View Full Code Here

        if (reasonText != null) {
            reasonBytes = reasonText.getBytes(CharsetUtil.UTF_8);
        }

        ByteBuf binaryData = Unpooled.buffer(2 + reasonBytes.length);
        binaryData.writeShort(statusCode);
        if (reasonBytes.length > 0) {
            binaryData.writeBytes(reasonBytes);
        }

        binaryData.readerIndex(0);
View Full Code Here

            int streams = streamsWithData.size();
            publishEvent(MuxyStreamEvent.BLOCK_FILE_WRITE, streams);
            int currentFileOffset = (int) openWriteFile.size();
            /* write out IDs in this block */
            ByteBuf metaBuffer = PooledByteBufAllocator.DEFAULT.directBuffer(2 + 4 * streams + 4 + 8 * streams);
            metaBuffer.writeShort(streams);
            int bodyOutputSize = 0;
            for (TempData out : streamsWithData) {
                metaBuffer.writeInt(out.meta.streamID);
                /* (4) chunk body offset (4) chunk length (n) chunk bytes */
                bodyOutputSize += 8 + out.snapshotLength;
View Full Code Here

      }

      // appearance!
      ByteBuf buffer = Unpooled.buffer(512);
      buffer = buffer.order(ByteOrder.LITTLE_ENDIAN);
      buffer.writeShort(6);
      buffer.writeShort(mapId);
      RawConverter.writeUnsignedByteArray(new short[] { 0x33, 0x36, 0x31, 0x30 }, buffer);
      buffer.writeByte((character.getLookHeight() << 4) | character.getLookSex());
      buffer.writeByte((character.getLookHairColor() << 4) | character.getLookSkinColor());
      buffer.writeByte((character.getProfessionprimary() << 4) | character.getLookHairStyle());
View Full Code Here

      // appearance!
      ByteBuf buffer = Unpooled.buffer(512);
      buffer = buffer.order(ByteOrder.LITTLE_ENDIAN);
      buffer.writeShort(6);
      buffer.writeShort(mapId);
      RawConverter.writeUnsignedByteArray(new short[] { 0x33, 0x36, 0x31, 0x30 }, buffer);
      buffer.writeByte((character.getLookHeight() << 4) | character.getLookSex());
      buffer.writeByte((character.getLookHairColor() << 4) | character.getLookSkinColor());
      buffer.writeByte((character.getProfessionprimary() << 4) | character.getLookHairStyle());
      buffer.writeByte((character.getLookCampaign() << 4) | character.getLookFace());
View Full Code Here

      // Redirect the client to the chosen Game Server
      ByteBuf buffer = Unpooled.buffer(24);
      buffer = buffer.order(ByteOrder.LITTLE_ENDIAN);
      // Why we need this is unknown
      buffer.writeShort(2);

      int selectedGameServerPort = selectedGameServer.getHostAndPort().getPort();

      // The bytes of the port must be reversed
      buffer = buffer.order(ByteOrder.BIG_ENDIAN);
View Full Code Here

      int selectedGameServerPort = selectedGameServer.getHostAndPort().getPort();

      // The bytes of the port must be reversed
      buffer = buffer.order(ByteOrder.BIG_ENDIAN);
      buffer.writeShort(selectedGameServerPort);
      buffer = buffer.order(ByteOrder.LITTLE_ENDIAN);

      // the GS should pass its public IP when it registers itself to the LS
      byte[] ipBytes = selectedGameServer.getHostAndPort().getAddress().getAddress();
View Full Code Here

            int streams = streamsWithData.size();
            publishEvent(MuxyStreamEvent.BLOCK_FILE_WRITE, streams);
            int currentFileOffset = (int) openWriteFile.size();
            /* write out IDs in this block */
            ByteBuf metaBuffer = PooledByteBufAllocator.DEFAULT.directBuffer(2 + 4 * streams + 4 + 8 * streams);
            metaBuffer.writeShort(streams);
            int bodyOutputSize = 0;
            for (TempData out : streamsWithData) {
                metaBuffer.writeInt(out.meta.streamID);
                /* (4) chunk body offset (4) chunk length (n) chunk bytes */
                bodyOutputSize += 8 + out.snapshotLength;
View Full Code Here

            int streams = streamsWithData.size();
            publishEvent(MuxyStreamEvent.BLOCK_FILE_WRITE, streams);
            int currentFileOffset = (int) openWriteFile.size();
            /* write out IDs in this block */
            ByteBuf metaBuffer = PooledByteBufAllocator.DEFAULT.directBuffer(2 + 4 * streams + 4 + 8 * streams);
            metaBuffer.writeShort(streams);
            int bodyOutputSize = 0;
            for (TempData out : streamsWithData) {
                metaBuffer.writeInt(out.meta.streamID);
                /* (4) chunk body offset (4) chunk length (n) chunk bytes */
                bodyOutputSize += 8 + out.snapshotLength;
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.