diff --git a/AX.WebDrillServer/Extensions/DateTimeExtensions.cs b/AX.WebDrillServer/Extensions/DateTimeExtensions.cs
index b844e91..de6ba8e 100644
--- a/AX.WebDrillServer/Extensions/DateTimeExtensions.cs
+++ b/AX.WebDrillServer/Extensions/DateTimeExtensions.cs
@@ -59,5 +59,18 @@
{
return (long)TimeSpan.FromTicks(time.Ticks - DateTime.UnixEpoch.Ticks).TotalMilliseconds - TimeZoneInfo.Local.GetUtcOffset(time).Hours * 60 * 60 * 1000;
}
+
+ ///
+ /// 将Unix时间戳转换为时间
+ ///
+ ///
+ ///
+ public static DateTime GetDateTimeFromUnix(long timeStamp)
+ {
+ DateTime startDt = TimeZoneInfo.ConvertTime(new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc), TimeZoneInfo.Local);
+ long lTime = timeStamp * 10000;
+ TimeSpan toNow = new TimeSpan(lTime);
+ return startDt.Add(toNow);
+ }
}
}
\ No newline at end of file
diff --git a/AX.WebDrillServer/Hubs/FireDeductionHub.cs b/AX.WebDrillServer/Hubs/FireDeductionHub.cs
index 61d6ac5..adb1894 100644
--- a/AX.WebDrillServer/Hubs/FireDeductionHub.cs
+++ b/AX.WebDrillServer/Hubs/FireDeductionHub.cs
@@ -221,6 +221,58 @@ namespace AX.WebDrillServer.Hubs
throw;
}
}
+ ///
+ /// 解散房间
+ ///
+ ///
+ ///
+ public async Task 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 上线下线处理
///
/// 上线处理
diff --git a/AX.WebDrillServer/Services/FireDeductionHub/FireDeductionRoomEnums.cs b/AX.WebDrillServer/Services/FireDeductionHub/FireDeductionRoomEnums.cs
index 5e4a6f1..339d83a 100644
--- a/AX.WebDrillServer/Services/FireDeductionHub/FireDeductionRoomEnums.cs
+++ b/AX.WebDrillServer/Services/FireDeductionHub/FireDeductionRoomEnums.cs
@@ -32,7 +32,11 @@
OnLine,//上线
OffLine,//下线
}
-
+ public enum RoomDisposeResult
+ {
+ Success,//成功
+ Failed,//失败
+ }
public enum DrillResult
{
Success,//成功
diff --git a/AX.WebDrillServer/appsettings.json b/AX.WebDrillServer/appsettings.json
index 5e08848..f0c010c 100644
--- a/AX.WebDrillServer/appsettings.json
+++ b/AX.WebDrillServer/appsettings.json
@@ -21,10 +21,10 @@
"Kestrel": {
"Endpoints": {
"Https": {
- "Url": "https://*:7011"
+ "Url": "https://*:7013"
},
"Http": {
- "Url": "http://*:5011"
+ "Url": "http://*:5013"
}
}
}