Exemplo n.º 1
0
        public async Task ReceiveFirst()
        {
            byte[] buffer      = new byte[1024 * 1024 * 3];
            var    receiveTask = NetworkIO.ReceiveAsync(connection, buffer, 0, 4, null, null, null);
            var    task        = Send(requests.Encode(), 0, requests.ByteLength);

            await receiveTask;

            await CompleteSendOrReceiveFirst(buffer);

            await task;
        }
Exemplo n.º 2
0
        public async Task ReceiveFirst()
        {
            var buffer     = new ByteBuffer(1024 * 1024 * 3);
            var sendBuffer = new ByteBuffer(requests.ByteLength);

            requests.Encode(sendBuffer.Data, 0);

            var receiveTask = NetworkIO.ReceiveAsync(connection, buffer, 0, 4, null, null, null);
            var task        = Send(sendBuffer, 0, requests.ByteLength);

            await receiveTask;

            await CompleteSendOrReceiveFirst(buffer);

            await task;
        }
Exemplo n.º 3
0
        public void ChunkedRequest()
        {
            rig.Manager.PieceManager.Picker.CancelRequests(id);

            rig.Manager.PieceManager.AddPieceRequests(id);
            requests = (RequestBundle)id.Dequeue();

            byte[] sendBuffer = requests.Encode();
            var    sendTask   = Send(sendBuffer, 0, sendBuffer.Length, 1);

            Assert.ThrowsAsync <ArgumentException> (() => sendTask);
        }
Exemplo n.º 4
0
        public void ChunkedRequest()
        {
            rig.Manager.PieceManager.CancelRequests(id);

            rig.Manager.PieceManager.AddPieceRequests(id);
            requests = (RequestBundle)id.MessageQueue.TryDequeue();

            using var releaser = SocketMemoryPool.Default.Rent(requests.ByteLength, out var buffer);
            requests.Encode(buffer.Span);
            var sendTask = Send(buffer, 1);

            Assert.ThrowsAsync <ArgumentException> (() => sendTask);
        }
Exemplo n.º 5
0
        public void ChunkedRequest()
        {
            rig.Manager.PieceManager.CancelRequests(id);

            rig.Manager.PieceManager.AddPieceRequests(id);
            requests = (RequestBundle)id.MessageQueue.TryDequeue();

            var sendBuffer = new ByteBuffer(requests.ByteLength);

            requests.Encode(sendBuffer.Data, 0);
            var sendTask = Send(sendBuffer, 0, sendBuffer.Data.Length, 1);

            Assert.ThrowsAsync <ArgumentException> (() => sendTask);
        }
Exemplo n.º 6
0
        public void Cancel_SendFirst()
        {
            using var releaser = SocketMemoryPool.Default.Rent(requests.ByteLength, out var sendBuffer);
            requests.Encode(sendBuffer.Span);
            var task = connection.SendAsync(sendBuffer).AsTask();

            connection.Dispose();
            Assert.CatchAsync <OperationCanceledException> (() => task);
        }