Exemplo n.º 1
0
        public static DataSlice FromBytes(Memory <byte> bytes, UdpContext context)
        {
            var slice = new DataSlice();
            var span  = bytes.Span;

            slice.Last      = MemoryMarshal.Read <bool>(span.Slice(0, 1));
            slice.Len       = MemoryMarshal.Read <int>(span.Slice(1, 4));
            slice.No        = MemoryMarshal.Read <long>(span.Slice(5, 8));
            slice.SessionId = MemoryMarshal.Read <Guid>(span.Slice(13, 16));
            slice.Slice     = bytes[29..];
 public async void FileDataHandler(UdpContext context)
 {
     await peer.FileDataReceived(DataSlice.FromBytes(context.Data, context));
 }