Esempio n. 1
0
 public unsafe byte ReadByte()
 {
     Check();
     fixed(byte *data = ByteBuffer)
     {
         if (!RakNetNative.NETRCV_ReadBytes(ptr, data, 1))
         {
             Console.WriteLine((object)"NETRCV_ReadBytes returned false");
             return(0);
         }
         return(ByteBuffer[0]);
     }
 }
Esempio n. 2
0
 private unsafe byte *Read(int size, byte *data)
 {
     Check();
     if (size > ReadBuffer.Length)
     {
         throw new Exception("Size > ReadBuffer.Length");
     }
     if (RakNetNative.NETRCV_ReadBytes(ptr, data, size))
     {
         return(data);
     }
     Console.WriteLine((object)"NETRCV_ReadBytes returned false");
     return(null);
 }
Esempio n. 3
0
 public unsafe int Read(byte[] buffer, int offset, int length)
 {
     if ((uint)offset > 0U)
     {
         throw new NotImplementedException("Offset != 0");
         fixed(byte *data = buffer)
         {
             if (!RakNetNative.NETRCV_ReadBytes(ptr, data, length))
             {
                 Console.WriteLine("NETRCV_ReadBytes returned false");
                 return(0);
             }
             return(length);
         }
 }
Esempio n. 4
0
 public unsafe MemoryStream ReadBytes(int length)
 {
     Check();
     if (length == -1)
     {
         length = incomingBytesUnread;
     }
     if (memoryStream.Capacity < length)
     {
         memoryStream.Capacity = length + 32;
         fixed(byte *data = memoryStream.GetBuffer())
         {
             memoryStream.SetLength(memoryStream.Capacity);
             if (!RakNetNative.NETRCV_ReadBytes(ptr, data, length))
             {
                 Console.WriteLine((object)"NETRCV_ReadBytes returned false");
                 return(null);
             }
             memoryStream.SetLength(length);
             return(memoryStream);
         }
 }