Ejemplo n.º 1
0
 /// <summary>
 /// Writes a boolean value using 1 bit
 /// </summary>
 public void Write(bool value)
 {
     EnsureBufferSize(m_bitLength + 1);
     NetBitWriter.WriteByte((value ? (byte)1 : (byte)0), 1, m_data, m_bitLength);
     m_bitLength += 1;
 }
Ejemplo n.º 2
0
 public void Write(UInt64 source)
 {
     EnsureBufferSize(m_bitLength + 64);
     NetBitWriter.WriteUInt64(source, 64, m_data, m_bitLength);
     m_bitLength += 64;
 }
Ejemplo n.º 3
0
 public void Write(UInt64 source, int numberOfBits)
 {
     EnsureBufferSize(m_bitLength + numberOfBits);
     NetBitWriter.WriteUInt64(source, numberOfBits, m_data, m_bitLength);
     m_bitLength += numberOfBits;
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Writes a signed 16 bit integer
 /// </summary>
 public void Write(Int16 source)
 {
     EnsureBufferSize(m_bitLength + 16);
     NetBitWriter.WriteUInt16((ushort)source, 16, m_data, m_bitLength);
     m_bitLength += 16;
 }
Ejemplo n.º 5
0
 public void Write(UInt32 source)
 {
     EnsureBufferSize(m_bitLength + 32);
     NetBitWriter.WriteUInt32(source, 32, m_data, m_bitLength);
     m_bitLength += 32;
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Reads the specified number of bytes without advancing the read pointer
 /// </summary>
 public void PeekBytes(byte[] into, int offset, int numberOfBytes)
 {
     NetBitWriter.ReadBytes(m_data, numberOfBytes, m_readPosition, into, offset);
 }
Ejemplo n.º 7
0
 public void Write(sbyte source)
 {
     EnsureBufferSize(m_bitLength + 8);
     NetBitWriter.WriteByte((byte)source, 8, m_data, m_bitLength);
     m_bitLength += 8;
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Reads the specified number of bits into a Byte without advancing the read pointer
        /// </summary>
        public byte PeekByte(int numberOfBits)
        {
            byte retval = NetBitWriter.ReadByte(m_data, numberOfBits, m_readPosition);

            return(retval);
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Reads the specified number of bytes without advancing the read pointer
 /// </summary>
 public byte[] PeekBytes(int numberOfBytes)
 {
     byte[] retval = new byte[numberOfBytes];
     NetBitWriter.ReadBytes(m_data, numberOfBytes, m_readPosition, retval, 0);
     return(retval);
 }
Ejemplo n.º 10
0
        public sbyte PeekSByte()
        {
            byte retval = NetBitWriter.ReadByte(m_data, 8, m_readPosition);

            return((sbyte)retval);
        }
Ejemplo n.º 11
0
        //
        // 1 bit
        //
        /// <summary>
        /// Reads a 1-bit Boolean without advancing the read pointer
        /// </summary>
        public bool PeekBoolean()
        {
            byte retval = NetBitWriter.ReadByte(m_data, 1, m_readPosition);

            return(retval > 0);
        }
Ejemplo n.º 12
0
        public UInt32 PeekUInt32()
        {
            uint retval = NetBitWriter.ReadUInt32(m_data, 32, m_readPosition);

            return(retval);
        }
Ejemplo n.º 13
0
        public UInt16 PeekUInt16()
        {
            uint retval = NetBitWriter.ReadUInt16(m_data, 16, m_readPosition);

            return((ushort)retval);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// write the size of the message to the beginning 2 bytes. Maximum of 65535 length supported.
        /// </summary>
        internal void WriteSize()
        {
            var size = LengthBytes - 2;

            NetBitWriter.WriteUInt16(checked ((ushort)size), 16, Data, 0);
        }