Fix Room List Not Updating On Clients Dynamically

Fix ``ChatHub`` Namespace
This commit is contained in:
Alan Moon 2025-06-21 10:41:29 -07:00
parent 818ba48924
commit df48a1491f
4 changed files with 6 additions and 7 deletions

View File

@ -1,5 +1,6 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using qtc_api.Hubs;
using qtc_api.Services.RoomService;
namespace qtc_api.Controllers
@ -22,7 +23,7 @@ namespace qtc_api.Controllers
public async Task<ActionResult<ServiceResponse<Room>>> CreateRoom(string userId, RoomDto request)
{
var response = await _roomService.AddRoom(userId, request);
await _hubContext.Clients.All.SendAsync("cf", "rul");
await _hubContext.Clients.All.SendAsync("cf", "rr");
return Ok(response);
}

View File

@ -14,12 +14,10 @@ namespace qtc_api.Controllers
public class UsersController : ControllerBase
{
private readonly IUserService _userService;
private readonly IConfiguration _configuration;
public UsersController(IUserService userService, IConfiguration configuration)
public UsersController(IUserService userService)
{
_userService = userService;
_configuration = configuration;
}
[HttpGet("all")]

View File

@ -1,6 +1,6 @@
using System.Text.Json;
namespace qtc_gateway.Hubs
namespace qtc_api.Hubs
{
[Authorize]
public class ChatHub : Hub
@ -46,7 +46,7 @@ namespace qtc_gateway.Hubs
ConnectedUsers.Add(new UserConnectionDto() { ConnectedUser = user, ConnectionId = Context.ConnectionId });
OnlineUsers.Add(user);
ServerConfig serverConfig = JsonSerializer.Deserialize<ServerConfig>(JsonDocument.Parse(File.ReadAllText("./ServerConfig.json")));
ServerConfig serverConfig = JsonDocument.Parse(File.ReadAllText("./ServerConfig.json")).Deserialize<ServerConfig>();
await Clients.Client(ConnectedUsers.FirstOrDefault(e => e.ConnectionId == Context.ConnectionId)!.ConnectionId!).SendAsync("rc", serverConfig);
await Clients.All.SendAsync("cf", "rul");

View File

@ -10,7 +10,7 @@ global using qtc_api.Services.UserService;
global using Microsoft.IdentityModel.Tokens;
global using System.Text;
global using qtc_api.Services.TokenService;
global using qtc_gateway.Hubs;
global using qtc_api.Hubs;
using qtc_api.Services.RoomService;
using qtc_api.Services.ContactService;
using Microsoft.EntityFrameworkCore.Diagnostics;