diff --git a/Yi.Furion.Net6/Yi.Furion.Application/Rbac/SignalRHub/OnlineUserHub.cs b/Yi.Furion.Net6/Yi.Furion.Application/Rbac/SignalRHub/OnlineUserHub.cs
index 87d52cc8..fe88ea7c 100644
--- a/Yi.Furion.Net6/Yi.Furion.Application/Rbac/SignalRHub/OnlineUserHub.cs
+++ b/Yi.Furion.Net6/Yi.Furion.Application/Rbac/SignalRHub/OnlineUserHub.cs
@@ -39,7 +39,7 @@ namespace Yi.Furion.Application.Rbac.SignalRHub
public override Task OnConnectedAsync()
{
var name = _currentUser.UserName;
- var loginUser = GetLoginLogInfo(_httpContext);
+ var loginUser = _httpContext.GetLoginLogInfo();
var user = clientUsers.Any(u => u.ConnnectionId == Context.ConnectionId);
//判断用户是否存在,否则添加集合
if (!user)
@@ -89,46 +89,5 @@ namespace Yi.Furion.Application.Rbac.SignalRHub
await Clients.All.SendAsync("ReceiveAllInfo", test);
}
- ///
- /// 获取客户端信息
- ///
- ///
- ///
- private static ClientInfo GetClientInfo(HttpContext context)
- {
- var str = context.GetUserAgent();
- var uaParser = Parser.GetDefault();
- ClientInfo c = uaParser.Parse(str);
- return c;
- }
-
- ///
- /// 记录用户登陆信息
- ///
- ///
- ///
- private static LoginLogEntity GetLoginLogInfo(HttpContext context)
- {
- var ipAddr = context.GetClientIp();
- IpInfo location;
- if (ipAddr == "127.0.0.1")
- {
- location = new IpInfo() { Province = "本地", City = "本机" };
- }
- else
- {
- location = IpTool.Search(ipAddr);
- }
- ClientInfo clientInfo = GetClientInfo(context);
- LoginLogEntity entity = new()
- {
- Browser = clientInfo.Device.Family,
- Os = clientInfo.OS.ToString(),
- LoginIp = ipAddr,
- LoginLocation = location.Province + "-" + location.City
- };
-
- return entity;
- }
}
}
\ No newline at end of file