Exemplo n.º 1
0
        /**
         * 写入变长的32位int变量
         *
         * @param output
         * @param value
         */

        public static void writeRawVarint32(SocketWriteBuffer output, int value)
        {
            int i = 0;

            while (i < 5)
            {
                if ((value & ~0x7F) == 0)
                {
                    output.writeByte((byte)value);
                    return;
                }
                else
                {
                    output.writeByte((byte)((value & 0x7F) | 0x80));
                    value = UnsignedRightShift(value, 7);
                }
                i++;
            }
        }
Exemplo n.º 2
0
        /**
         * 有符号int写入buff,变长
         *
         * @param output
         * @param value
         */

        public static void writeSInt(SocketWriteBuffer output, int value)
        {
            writeRawVarint32(output, encodeZigZag32(value));
        }