1234567891011121314151617181920212223242526272829303132333435 |
- using Microsoft.AspNetCore.SignalR;
- using MTWorkHR.Application.Identity;
- using MTWorkHR.Core.Global;
- using MTWorkHR.Core.UnitOfWork;
- namespace MTWorkHR.API.Chat
- {
- public class Chat : Hub
- {
- private readonly IUnitOfWork _unitOfWork;
- public Chat(IUnitOfWork unitOfWork)
- {
- _unitOfWork = unitOfWork;
- }
- public async Task getOnlineUsers()
- {
- //var allConnections = await _unitOfWork.Connection.GetAllAsync();
- //var currUserId = allConnections.Item1.Where(c => c.SignalrId == Context.ConnectionId).Select(c => c.UserId).SingleOrDefault();
- //List<User> onlineUsers = allConnections
- // .Where(c => c.PersonId != currUserId)
- // .Select(c =>
- // new UserDto(c.PersonId, ctx.Person.Where(p => p.Id == c.PersonId).Select(p => p.Name).SingleOrDefault(), c.SignalrId)
- // ).ToList();
- //await Clients.Caller.SendAsync("getOnlineUsersResponse", onlineUsers);
- }
- public async Task sendMsg(string connId, string msg)
- {
- await Clients.Client(connId).SendAsync("sendMsgResponse", Context.ConnectionId, msg);
- }
- }
- }
|