Commit dc84b5e4 by lcx

no message

parent bab0aefb
...@@ -26,32 +26,21 @@ NotificationsService service ...@@ -26,32 +26,21 @@ NotificationsService service
this.logger = logger; this.logger = logger;
this.service = service; this.service = service;
} }
private readonly MemoryCacheHelper helper = new MemoryCacheHelper();
public override Task OnConnectedAsync()
{
var task = base.OnConnectedAsync();
Clients.Caller.SendAsync("ReceiveMessage", Context.ConnectionId);
return task;
}
public override Task OnDisconnectedAsync(Exception exception) private readonly MemoryCacheHelper helper = new MemoryCacheHelper();
{
return base.OnDisconnectedAsync(exception);
}
public void LoginService(int userId) public void LoginService(int userId)
{ {
//var dateTime = DateTime.Now; var dateTime = DateTime.Now;
//var slidingtimespan = helper.ToUnixTimestampBySeconds(dateTime.AddMinutes(30)); var slidingtimespan = helper.ToUnixTimestampBySeconds(dateTime.AddMinutes(30));
//var absolutetimespan = helper.ToUnixTimestampBySeconds(dateTime.AddHours(2)); var absolutetimespan = helper.ToUnixTimestampBySeconds(dateTime.AddHours(2));
//helper.Set(userId.ToString(), Context.ConnectionId, slidingtimespan, absolutetimespan); helper.Set(userId.ToString(), Context.ConnectionId, slidingtimespan, absolutetimespan);
} }
public void LogoutService(int userId) public void LogoutService(int userId)
{ {
//if (helper.Exists(userId.ToString())) if (helper.Exists(userId.ToString()))
// helper.Remove(userId.ToString()); helper.Remove(userId.ToString());
} }
} }
} }
...@@ -12,19 +12,18 @@ public class NotificationsService : IAutoInjection ...@@ -12,19 +12,18 @@ public class NotificationsService : IAutoInjection
{ {
private readonly ILogger logger; private readonly ILogger logger;
private readonly IHubContext<AllotLogHub> hubContext; private readonly IHubContext<AllotLogHub> hubContext;
private readonly MemoryCacheHelper helper;
public NotificationsService( public NotificationsService(
ILogger<NotificationsService> logger, ILogger<NotificationsService> logger,
IHubContext<AllotLogHub> hubContext, IHubContext<AllotLogHub> hubContext
MemoryCacheHelper helper
) )
{ {
this.logger = logger; this.logger = logger;
this.hubContext = hubContext; this.hubContext = hubContext;
this.helper = helper;
} }
private readonly MemoryCacheHelper helper = new MemoryCacheHelper();
public void SendMessage(int userId, MessageInfo data) public void SendMessage(int userId, MessageInfo data)
{ {
string key = userId.ToString(); string key = userId.ToString();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment