public override UInt16 Read(Byte[] buf, UInt16 offset, int len) { if (len >= offset + 2) { m_Vlue = NetPacketHeader.NtohUint16(buf, offset); return(2); } return(0); }
public override UInt16 Read(Byte[] buf, UInt16 offset, int len) { //int i = offset; //while (buf[i] != 0) //{ // i++; //} ushort length = NetPacketHeader.NtohUint16(buf, offset); string str = Encoding.UTF8.GetString(buf, offset + 2, length); m_Vlue = str; return((UInt16)(length + 2)); }
protected UInt16 ReadArrayHead(Byte[] buf, UInt16 offset) { if (m_bBigArray) { m_nLen = NetPacketHeader.NtohUint16(buf, offset); return(2); } else { m_nLen = buf[offset]; } return(1); }
public static String NtohString(Byte[] buf, int offset, out UInt16 len) { ushort length = NetPacketHeader.NtohUint16(buf, offset); if (m_IsBigEndian) { Array.Reverse(buf, offset, length + 2); } len = (ushort)(length + 2); string str = Encoding.UTF8.GetString(buf, offset + 2, length); return(str); }
public override UInt16 Read(Byte[] buf, UInt16 offset, int len) { UInt16[] buffer; UInt16 nResult = offset; UInt16 n = ReadArrayHead(buf, offset); if (len > offset + n + m_nLen * 2) { offset += n; buffer = new UInt16[m_nLen]; for (n = 0; n < m_nLen; ++n) { buffer[n] = NetPacketHeader.NtohUint16(buf, offset); offset += 2; } m_Vlue = buffer; return((UInt16)(offset - nResult)); } return(0); }