forked from powerfun/udpservice
修复删除连接客户端时会崩溃的异常
This commit is contained in:
parent
f33dd4fa2e
commit
25c34c0b88
@ -259,7 +259,7 @@ namespace OnlineUserPool.ViewModels
|
||||
|
||||
private void SendMessage(Collection<HostModel> clients, List<MsgModel> msgModels)
|
||||
{
|
||||
if (!clients.Any())
|
||||
if (!clients.Any() || !msgModels.Any())
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -405,16 +405,23 @@ namespace OnlineUserPool.ViewModels
|
||||
}
|
||||
|
||||
private void CientDisconnected(EndPoint point)
|
||||
{
|
||||
dispatcher.Invoke(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
var client = Clients.FirstOrDefault(f => f.IPEndPoint.ToString() == point.ToString());
|
||||
if (client != null)
|
||||
{
|
||||
dispatcher.Invoke(() =>
|
||||
{
|
||||
Clients.Remove(client);
|
||||
});
|
||||
}
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
Log.Information("在CientDisconnected触发以后,删除client时报错了,"+ ex.Message +", " + ex.StackTrace);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public class Data1
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user