Example #1
0
    public unsafe MemoryStream ReadBytes(int length, bool compressed)
    {
        Check();
        MemoryStream memoryStream = new MemoryStream();

        if (length == -1)
        {
            length = incomingBytesUnread;
        }
        if (memoryStream.Capacity < length)
        {
            memoryStream.Capacity = length + 32;
            fixed(byte *data = memoryStream.GetBuffer())
            {
                memoryStream.SetLength(memoryStream.Capacity);

                if (!RakNet_Native.NETRCV_ReadBytes(ptr, data, length))
                {
                    Debug.LogWarning("[RakNet] NETRCV_ReadBytes returned false");
                    return(null);
                }
                memoryStream.SetLength(length);
                return(memoryStream);
            }
    }
Example #2
0
 public unsafe byte ReadByte()
 {
     Check();
     fixed(byte *data = ByteBuffer)
     {
         if (!RakNet_Native.NETRCV_ReadBytes(ptr, data, 1))
         {
             Debug.LogWarning("[RakNet] NETRCV_ReadBytes returned false");
             return(0);
         }
         return(ByteBuffer[0]);
     }
 }
Example #3
0
    private unsafe byte *Read(int size, byte *data)
    {
        Check();
        if (size > ReadBuffer.Length)
        {
            throw new Exception("[RakNet] Size > ReadBuffer.Length");
        }

        if (RakNet_Native.NETRCV_ReadBytes(ptr, data, size))
        {
            return(data);
        }

        Debug.LogWarning("[RakNet] NETRCV_ReadBytes returned false");
        return(null);
    }
Example #4
0
 protected unsafe virtual bool Read(byte *data, int length, bool compressed)
 {
     Check();
     return(RakNet_Native.NETRCV_ReadBytes(ptr, data, length));
 }