/// <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; }
public void Write(UInt64 source) { EnsureBufferSize(m_bitLength + 64); NetBitWriter.WriteUInt64(source, 64, m_data, m_bitLength); m_bitLength += 64; }
public void Write(UInt64 source, int numberOfBits) { EnsureBufferSize(m_bitLength + numberOfBits); NetBitWriter.WriteUInt64(source, numberOfBits, m_data, m_bitLength); m_bitLength += numberOfBits; }
/// <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; }
public void Write(UInt32 source) { EnsureBufferSize(m_bitLength + 32); NetBitWriter.WriteUInt32(source, 32, m_data, m_bitLength); m_bitLength += 32; }
/// <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); }
public void Write(sbyte source) { EnsureBufferSize(m_bitLength + 8); NetBitWriter.WriteByte((byte)source, 8, m_data, m_bitLength); m_bitLength += 8; }
/// <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); }
/// <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); }
public sbyte PeekSByte() { byte retval = NetBitWriter.ReadByte(m_data, 8, m_readPosition); return((sbyte)retval); }
// // 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); }
public UInt32 PeekUInt32() { uint retval = NetBitWriter.ReadUInt32(m_data, 32, m_readPosition); return(retval); }
public UInt16 PeekUInt16() { uint retval = NetBitWriter.ReadUInt16(m_data, 16, m_readPosition); return((ushort)retval); }
/// <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); }