Commit dc84b5e4 by lcx

no message

parent bab0aefb
......@@ -26,32 +26,21 @@ NotificationsService service
this.logger = logger;
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)
{
return base.OnDisconnectedAsync(exception);
}
private readonly MemoryCacheHelper helper = new MemoryCacheHelper();
public void LoginService(int userId)
{
//var dateTime = DateTime.Now;
//var slidingtimespan = helper.ToUnixTimestampBySeconds(dateTime.AddMinutes(30));
//var absolutetimespan = helper.ToUnixTimestampBySeconds(dateTime.AddHours(2));
//helper.Set(userId.ToString(), Context.ConnectionId, slidingtimespan, absolutetimespan);
var dateTime = DateTime.Now;
var slidingtimespan = helper.ToUnixTimestampBySeconds(dateTime.AddMinutes(30));
var absolutetimespan = helper.ToUnixTimestampBySeconds(dateTime.AddHours(2));
helper.Set(userId.ToString(), Context.ConnectionId, slidingtimespan, absolutetimespan);
}
public void LogoutService(int userId)
{
//if (helper.Exists(userId.ToString()))
// helper.Remove(userId.ToString());
if (helper.Exists(userId.ToString()))
helper.Remove(userId.ToString());
}
}
}
......@@ -12,19 +12,18 @@ public class NotificationsService : IAutoInjection
{
private readonly ILogger logger;
private readonly IHubContext<AllotLogHub> hubContext;
private readonly MemoryCacheHelper helper;
public NotificationsService(
ILogger<NotificationsService> logger,
IHubContext<AllotLogHub> hubContext,
MemoryCacheHelper helper
IHubContext<AllotLogHub> hubContext
)
{
this.logger = logger;
this.hubContext = hubContext;
this.helper = helper;
}
private readonly MemoryCacheHelper helper = new MemoryCacheHelper();
public void SendMessage(int userId, MessageInfo data)
{
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