WhiteCharun
WhiteCharun
CC#
Created by WhiteCharun on 3/7/2025 in #help
✅ [Docker Compose] The path must be absolute. (Parameter 'root')
I added docker orchestration to my MVC project using Docker Compose but when I start the application in debug mode I get System.ArgumentException: 'The path must be absolute. (Parameter 'root')' on the line var builder = WebApplication.CreateBuilder(args);. The strange thing is that I don't get that exception in release mode.
52 replies
CC#
Created by WhiteCharun on 3/5/2025 in #help
✅ [SignalR] How to effeciently keep track of ConnectionIds.
I'm currently trying to build a little chat room where users can send messages. The thing I can't get over my head is if this is the best way to keep track of connection Ids. Since there could be multiple tabs open i want to send the message to all the tabs so I need to make a persistant layer where I associate an id and username with the connection Id of signalR. On the client side as soon as i connect to the websocket server i call the RegisterUser
public class ChatHub : Hub
{
private readonly IConnectionManager _connectionManager;

public ChatHub(IConnectionManager connectionManager)
{
_connectionManager = connectionManager;
}

public async Task SendMessage(UserChatHubDTO user, string message)
{

await Clients.All.SendAsync("ReceiveMessage", user, message);

}
public void RegisterUser(UserChatHubDTO user)
{
_connectionManager.AddConnection(Context.ConnectionId, user);
}

public override async Task OnDisconnectedAsync(Exception exception)
{
_connectionManager.RemoveConnection(Context.ConnectionId);
await base.OnDisconnectedAsync(exception);
}
}
public class ChatHub : Hub
{
private readonly IConnectionManager _connectionManager;

public ChatHub(IConnectionManager connectionManager)
{
_connectionManager = connectionManager;
}

public async Task SendMessage(UserChatHubDTO user, string message)
{

await Clients.All.SendAsync("ReceiveMessage", user, message);

}
public void RegisterUser(UserChatHubDTO user)
{
_connectionManager.AddConnection(Context.ConnectionId, user);
}

public override async Task OnDisconnectedAsync(Exception exception)
{
_connectionManager.RemoveConnection(Context.ConnectionId);
await base.OnDisconnectedAsync(exception);
}
}
7 replies