From 65c19a5071940fc49e75c714d34549c689286d94 Mon Sep 17 00:00:00 2001 From: lishuo Date: Thu, 27 Jul 2023 18:07:42 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E6=88=BF=E9=97=B4?= =?UTF-8?q?=E5=B7=B2=E7=BB=8F=E7=BB=93=E6=9D=9F=E4=BA=86=E4=BD=86=E6=98=AF?= =?UTF-8?q?=E6=88=BF=E9=97=B4=E5=86=85=E7=9A=84=E4=BA=BA=E7=89=A9=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E8=A2=AB=E6=B8=85=E7=A9=BA=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ViewModels/MainWindowViewModel.cs | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/ViewModels/MainWindowViewModel.cs b/ViewModels/MainWindowViewModel.cs index 51906b1..d72889d 100644 --- a/ViewModels/MainWindowViewModel.cs +++ b/ViewModels/MainWindowViewModel.cs @@ -438,10 +438,10 @@ namespace OnlineUserPool.ViewModels //先移除当前用户在其他房间的信息(考虑服务器重启的时候没有响应客户端退出命令) private void RemoveOtherRoomInfo(int userId, int roomId) { - var preRoom = RoomList.ToList().Where(c => c.Status == 0 && c.List.Where(c => c.UserId == userId).Any() && c.RoomId != roomId).FirstOrDefault(); + var preRoom = RoomList.ToList().FirstOrDefault(c => c.Status == 0 && c.List.Any(a => a.UserId == userId) && c.RoomId != roomId); if (preRoom != null) { - var needRemove = preRoom.List.Where(c => c.UserId == userId).FirstOrDefault(); + var needRemove = preRoom.List.FirstOrDefault(c => c.UserId == userId && c.Saved == false); preRoom.List.Remove(needRemove); if (preRoom.List.Count == 0) { @@ -794,7 +794,7 @@ namespace OnlineUserPool.ViewModels SendDataSize = $"\t单客户端数据包V1:{ data1.GetBytes().Length / 1000D }KB,一共占用带宽:{ data1.GetBytes().Length / 1000D * clients1.Count }KB,压缩以后{ data1.GetBytes(true).Length / 1000D * clients1.Count }KB"; - #region udp发送数据 + #region 发送数据 foreach (var item in clients1) { try @@ -846,14 +846,6 @@ namespace OnlineUserPool.ViewModels } } #endregion - - //#region tcp发送数据 - //var tcpClient = clients1.Where(c => c.Service is TcpService1).FirstOrDefault(); - //if(tcpClient != null) - //{ - // tcpClient.Service.Send(dataV1, dataV1.Length, null); - //} - //#endregion } private void GameRoomDisConnectHandler(HostModel client) @@ -865,7 +857,7 @@ namespace OnlineUserPool.ViewModels RoomList.ToList().ForEach(o => { if (o.List != null && o.Status != 2) { - var needRemove = o.List.Where(c => c.UserId == client.MemberId).FirstOrDefault(); + var needRemove = o.List.FirstOrDefault(c => c.UserId == client.MemberId && c.Saved == false); o.List.Remove(needRemove); } }); @@ -932,7 +924,7 @@ namespace OnlineUserPool.ViewModels var room = RoomList.ToList().FirstOrDefault(c => c.RoomId == client.RoomId); if(room == null)return; - var needRemove = room.List.FirstOrDefault(c => c.UserId == client.MemberId); + var needRemove = room.List.FirstOrDefault(c => c.UserId == client.MemberId && c.Saved == false); if(needRemove == null)return; //从房间中移除,并考虑是否需要删除房间和移交房主