|
|
|
@ -221,6 +221,58 @@ namespace AX.WebDrillServer.Hubs
|
|
|
|
|
throw; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
/// <summary> |
|
|
|
|
/// 解散房间 |
|
|
|
|
/// </summary> |
|
|
|
|
/// <returns></returns> |
|
|
|
|
/// <exception cref="Exception"></exception> |
|
|
|
|
public async Task<RoomDisposeResultData> CallServer_DisposeRoom() |
|
|
|
|
{ |
|
|
|
|
RoomDisposeResultData resultData = new(); |
|
|
|
|
var userId = Context.UserIdentifier; |
|
|
|
|
try |
|
|
|
|
{ |
|
|
|
|
var room = roomManager.GetRoomByUserId(userId!); |
|
|
|
|
|
|
|
|
|
if (room == null) |
|
|
|
|
{ |
|
|
|
|
resultData.Result = RoomDisposeResult.Failed; |
|
|
|
|
resultData.RoomId = ""; |
|
|
|
|
return resultData; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
if (room.Owner == userId) |
|
|
|
|
{ |
|
|
|
|
resultData.Result = RoomDisposeResult.Success; |
|
|
|
|
resultData.RoomId = room.RoomId; |
|
|
|
|
|
|
|
|
|
await Clients.Group(room.RoomId).SendAsync("CallWeb_disposeRoom", resultData); |
|
|
|
|
//房间中用户的房间信息重置 |
|
|
|
|
foreach (var item in room.Users) |
|
|
|
|
{ |
|
|
|
|
item.RoomId = ""; |
|
|
|
|
} |
|
|
|
|
//房间缓存移除该房间 |
|
|
|
|
roomManager.RemoveRoom(room.RoomId); |
|
|
|
|
//通知web端刷新房间列表 |
|
|
|
|
await Clients.All.SendAsync("callWeb_refreshRoomList", roomManager.GetAllRooms()); |
|
|
|
|
|
|
|
|
|
return resultData; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
resultData.Result = RoomDisposeResult.Failed; |
|
|
|
|
resultData.RoomId = room.RoomId; |
|
|
|
|
return resultData; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
catch (Exception e) |
|
|
|
|
{ |
|
|
|
|
throw new Exception(e.Message); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
#region 推演API |
|
|
|
@ -427,6 +479,7 @@ namespace AX.WebDrillServer.Hubs
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
#region 上线下线处理 |
|
|
|
|
/// <summary> |
|
|
|
|
/// 上线处理 |
|
|
|
|