Skip to content
Snippets Groups Projects
Commit 425dea8a authored by Enzo Santangelo Dodera's avatar Enzo Santangelo Dodera
Browse files

Update ChatHub.cs

parent c8f82062
No related branches found
No related tags found
2 merge requests!20merge from develop,!18Feature/chat signalr
using AutoMapper;
using AutoMapper;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.SignalR;
......@@ -38,15 +38,12 @@ namespace Tsi1.Api.SignalR
public override async Task OnConnectedAsync()
{
var httpContext = Context.GetHttpContext();
//var otherUser = httpContext.Request.Query["user"].ToString();
var otherUserId = int.Parse(httpContext.Request.Query["id"].ToString());
//var userName = Context.User.FindFirst("Username").Value;
var otherUserId = int.Parse(httpContext.Request.Query["id"].ToString());
var userId = int.Parse(Context.User.Claims.FirstOrDefault(x => x.Type == "Id").Value);
var tenantId = int.Parse(Context.User.Claims.FirstOrDefault(x => x.Type == "TenantId").Value);
var groupName = GetGroupName(userId, otherUserId);
await Groups.AddToGroupAsync(Context.ConnectionId, groupName);
......@@ -95,7 +92,6 @@ namespace Tsi1.Api.SignalR
var messageDto = await _messageService.Send(newMessage);
await Clients.Group(groupName).SendAsync("NewMessage", messageDto);
}
private async Task<Group> AddToGroup(string groupName)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment