forked from powerfun/udpservice
房间状态为进行中,如果房间为空也要删除房间
This commit is contained in:
parent
22e77b1d46
commit
bc0499b9f4
@ -10,7 +10,7 @@ namespace OnlineUserPool.Model
|
||||
public int RoomId { get; set; }
|
||||
public string Name { get; set; }
|
||||
public int UserId { get; set; }//房主
|
||||
public int Status { get; set; }//房间状态 0 :准备状态 1:开始loading
|
||||
public int Status { get; set; }//房间状态 0 :准备状态 1:开始loading 2:结束
|
||||
public DateTime StatusChangedTime { get; set; }
|
||||
public DateTime CreateTime { get; set; }//创建时间
|
||||
public DateTime? StartTime { get; set; }//开始时间
|
||||
|
||||
@ -528,7 +528,7 @@ namespace OnlineUserPool.ViewModels
|
||||
if (needRemove != null)
|
||||
{
|
||||
list.Remove(needRemove);
|
||||
//如果当前是房主退出房间,房主替换成其他人
|
||||
//如果当前是房主退出房间,房主替换成其他人, 房主客户端中断也算
|
||||
if (needRemove.IsOwner && list.Count() > 0)
|
||||
{
|
||||
var newOwner = list.FirstOrDefault();
|
||||
@ -537,7 +537,7 @@ namespace OnlineUserPool.ViewModels
|
||||
}
|
||||
}
|
||||
//人数为0,删除房间
|
||||
if (list.Count() == 0 && room.Status == 0)
|
||||
if (list.Count() == 0)
|
||||
{
|
||||
RoomList.Remove(room);
|
||||
}
|
||||
@ -845,18 +845,18 @@ namespace OnlineUserPool.ViewModels
|
||||
|
||||
private void GameRoomDisConnectHandler(HostModel client)
|
||||
{
|
||||
//如果是在对战房间或者对战列表掉线执行,骑行阶段断开连接不移除房间信息
|
||||
if (client.Model != null && !client.Model.Equals("GameRoom"))
|
||||
return;
|
||||
////如果是在对战房间或者对战列表掉线执行,骑行阶段断开连接不移除房间信息
|
||||
//if (client.Model != null && !client.Model.Equals("GameRoom"))
|
||||
// return;
|
||||
|
||||
RoomList.ToList().ForEach(o => {
|
||||
if (o.List != null && o.Status == 0)
|
||||
if (o.List != null && o.Status != 2)
|
||||
{
|
||||
var needRemove = o.List.Where(c => c.UserId == client.MemberId).FirstOrDefault();
|
||||
o.List.Remove(needRemove);
|
||||
}
|
||||
});
|
||||
var needRemoveList = RoomList.ToList().Where(c => c.List.Count == 0 && c.Status == 0).ToList();
|
||||
var needRemoveList = RoomList.ToList().Where(c => c.List.Count == 0 && c.Status != 2).ToList();
|
||||
foreach (var item in needRemoveList)
|
||||
{
|
||||
RoomList.Remove(item);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user