コード例 #1
0
 public override UInt16 Read(Byte[] buf, UInt16 offset, int len)
 {
     if (len >= offset + 2)
     {
         m_Vlue = NetPacketHeader.NtohUint16(buf, offset);
         return(2);
     }
     return(0);
 }
コード例 #2
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));
        }
コード例 #3
0
 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);
 }
コード例 #4
0
        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);
        }
コード例 #5
0
        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);
        }