use raw buffer for frist connect msg then use buffered stream to read more efficient

This commit is contained in:
Eggers Jan
2017-09-13 09:14:08 +02:00
parent 6c7e70f78a
commit c7c1691d75
9 changed files with 35 additions and 20 deletions
@@ -393,6 +393,8 @@ namespace MQTTnet.Core.Tests
public Stream ReceiveStream => _stream;
public Stream RawStream => _stream;
public Stream SendStream => _stream;
public bool IsConnected { get; } = true;
@@ -1,6 +1,7 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using MQTTnet.Core.Adapter;
using MQTTnet.Core.Client;
@@ -46,6 +47,11 @@ namespace MQTTnet.Core.Tests
return Task.Run(() => _incomingPackets.Take());
}
public IEnumerable<MqttBasePacket> ReceivePackets( CancellationToken cancellationToken )
{
return _incomingPackets.GetConsumingEnumerable();
}
private void SendPacketInternal(MqttBasePacket packet)
{
if (packet == null) throw new ArgumentNullException(nameof(packet));
@@ -17,7 +17,7 @@ namespace MQTTnet.TestApp.NetFramework
public static async Task RunAsync()
{
var server = Task.Run(() => RunServerAsync());
var client = Task.Run(() => RunClientAsync(500, TimeSpan.FromMilliseconds(10)));
var client = Task.Run(() => RunClientAsync(300, TimeSpan.FromMilliseconds(10)));
await Task.WhenAll(server, client).ConfigureAwait(false);
}