Exemplo n.º 1
0
        internal void OnMessageReceived(IntPtr data, ulong size)
        {
            //< TODO - .NET Standard 2.1
            //https://docs.microsoft.com/en-us/dotnet/api/system.readonlyspan-1.-ctor?view=netstandard-2.1#System_ReadOnlySpan_1__ctor_System_Void__System_Int32_
            //var span = new ReadOnlySpan<byte>(data, size);
            //MessageReceived?.Invoke(span);

            if (MessageReceived != null)
            {
                byte[] msg = new byte[size];
                unsafe
                {
                    fixed(void *ptr = msg)
                    {
                        PeerConnection.MemCpy(ptr, (void *)data, size);
                    }
                }
                MessageReceived.Invoke(msg);
            }
        }