Time out if no local units are found in 1 second

This commit is contained in:
2019-02-20 15:08:33 -06:00
parent 3e4084714b
commit 9655b95898

View File

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Sockets;
using System.Threading.Tasks;
@ -28,13 +29,16 @@ namespace ScreenLogicConnect
{
await udpClient.SendAsync(broadcastData, broadcastData.Length, new IPEndPoint(IPAddress.Broadcast, multicastPort));
var buf = await udpClient.ReceiveAsync();
var buf = await udpClient.ReceiveAsync().TimeoutAfter(TimeSpan.FromSeconds(1));
if (buf != null)
{
var findServerResponse = new EasyTouchUnit(buf);
if (findServerResponse.isValid)
{
units.Add(findServerResponse);
}
}
}
return units;
}