Time out if no local units are found in 1 second
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user