|
@@ -1,6 +1,7 @@
|
|
using Microsoft.AspNetCore.Identity;
|
|
using Microsoft.AspNetCore.Identity;
|
|
using Microsoft.AspNetCore.SignalR;
|
|
using Microsoft.AspNetCore.SignalR;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
+using Microsoft.Extensions.Logging;
|
|
using MimeKit;
|
|
using MimeKit;
|
|
using MTWorkHR.Application.Filters;
|
|
using MTWorkHR.Application.Filters;
|
|
using MTWorkHR.Application.Identity;
|
|
using MTWorkHR.Application.Identity;
|
|
@@ -27,13 +28,14 @@ namespace MTWorkHR.API.Chat
|
|
private readonly GlobalInfo _globalInfo;
|
|
private readonly GlobalInfo _globalInfo;
|
|
//private readonly UserService _userService;
|
|
//private readonly UserService _userService;
|
|
private readonly ApplicationUserManager _userManager;
|
|
private readonly ApplicationUserManager _userManager;
|
|
-
|
|
|
|
- public ChatHub(IUnitOfWork unitOfWork, GlobalInfo globalInfo, ApplicationUserManager userManager /*, UserService userService*/)
|
|
|
|
|
|
+ private readonly ILogger<ChatHub> _logger;
|
|
|
|
+ public ChatHub(IUnitOfWork unitOfWork, GlobalInfo globalInfo, ApplicationUserManager userManager /*, UserService userService*/, ILogger<ChatHub> logger)
|
|
{
|
|
{
|
|
_unitOfWork = unitOfWork;
|
|
_unitOfWork = unitOfWork;
|
|
_globalInfo = globalInfo;
|
|
_globalInfo = globalInfo;
|
|
// _userService = userService;
|
|
// _userService = userService;
|
|
_userManager = userManager;
|
|
_userManager = userManager;
|
|
|
|
+ _logger = logger;
|
|
}
|
|
}
|
|
|
|
|
|
public async Task GetUsers()
|
|
public async Task GetUsers()
|
|
@@ -73,7 +75,8 @@ namespace MTWorkHR.API.Chat
|
|
}catch(Exception e)
|
|
}catch(Exception e)
|
|
{
|
|
{
|
|
var m = e.Message;
|
|
var m = e.Message;
|
|
- Console.WriteLine(e.Message);
|
|
|
|
|
|
+
|
|
|
|
+ _logger.LogError(e, e.Message);
|
|
}
|
|
}
|
|
|
|
|
|
return response;
|
|
return response;
|
|
@@ -97,7 +100,7 @@ namespace MTWorkHR.API.Chat
|
|
|
|
|
|
// Send a message from one user to another
|
|
// Send a message from one user to another
|
|
|
|
|
|
- public async Task sendMsg(string receiverUserId, string msg)
|
|
|
|
|
|
+ public async Task SendMessage(string receiverUserId, string msg)
|
|
{
|
|
{
|
|
try
|
|
try
|
|
{
|
|
{
|
|
@@ -120,7 +123,7 @@ namespace MTWorkHR.API.Chat
|
|
await Clients.Client(receiverconnIdDB).SendAsync("ReceiveMessage", messag);
|
|
await Clients.Client(receiverconnIdDB).SendAsync("ReceiveMessage", messag);
|
|
await Clients.Caller.SendAsync("ReceiveMessage", messag);
|
|
await Clients.Caller.SendAsync("ReceiveMessage", messag);
|
|
}
|
|
}
|
|
- catch (Exception e) { }
|
|
|
|
|
|
+ catch (Exception e) { _logger.LogError(e, e.Message); }
|
|
}
|
|
}
|
|
|
|
|
|
// Get previous messages between two users
|
|
// Get previous messages between two users
|
|
@@ -196,7 +199,7 @@ namespace MTWorkHR.API.Chat
|
|
await Clients.Caller.SendAsync("authMeResponseFail");
|
|
await Clients.Caller.SendAsync("authMeResponseFail");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- catch (Exception ex) { }
|
|
|
|
|
|
+ catch (Exception e) { _logger.LogError(e, e.Message); }
|
|
|
|
|
|
await base.OnConnectedAsync();
|
|
await base.OnConnectedAsync();
|
|
}
|
|
}
|