WhiteCharun
WhiteCharun
CC#
Created by WhiteCharun on 3/7/2025 in #help
✅ [Docker Compose] The path must be absolute. (Parameter 'root')
Thanks
52 replies
CC#
Created by WhiteCharun on 3/7/2025 in #help
✅ [Docker Compose] The path must be absolute. (Parameter 'root')
52 replies
CC#
Created by WhiteCharun on 3/7/2025 in #help
✅ [Docker Compose] The path must be absolute. (Parameter 'root')
It's just that it's the default program.cs of asp.net
var builder = WebApplication.CreateBuilder(args);

// Add services to the container.
builder.Services.AddControllersWithViews();

// Add SignalR
builder.Services.AddSignalR();
builder.Services.AddSingleton<IConnectionManager, ConnectionManager>();
builder.Services.AddSingleton<HtmlSanitizer>();

builder.Services.AddSession();

var app = builder.Build();

// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Home/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}

app.UseHttpsRedirection();
app.UseStaticFiles();

app.UseRouting();

app.UseAuthorization();

app.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");


app.MapHub<ChatHub>("chatHub");

app.UseSession();

app.Run();
var builder = WebApplication.CreateBuilder(args);

// Add services to the container.
builder.Services.AddControllersWithViews();

// Add SignalR
builder.Services.AddSignalR();
builder.Services.AddSingleton<IConnectionManager, ConnectionManager>();
builder.Services.AddSingleton<HtmlSanitizer>();

builder.Services.AddSession();

var app = builder.Build();

// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Home/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}

app.UseHttpsRedirection();
app.UseStaticFiles();

app.UseRouting();

app.UseAuthorization();

app.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");


app.MapHub<ChatHub>("chatHub");

app.UseSession();

app.Run();
52 replies
CC#
Created by WhiteCharun on 3/7/2025 in #help
✅ [Docker Compose] The path must be absolute. (Parameter 'root')
Wrong post?
52 replies
CC#
Created by WhiteCharun on 3/5/2025 in #help
✅ [SignalR] How to effeciently keep track of ConnectionIds.
Thanks
7 replies
CC#
Created by WhiteCharun on 3/5/2025 in #help
✅ [SignalR] How to effeciently keep track of ConnectionIds.
public interface IConnectionManager
{
void AddConnection(string connectionId, UserChatHubDTO user);
void RemoveConnection(string connectionId);
IEnumerable<string> GetConnectionIds(string anonymousUserId);
}

public class ConnectionManager : IConnectionManager
{
private readonly ConcurrentDictionary<string, UserChatHubDTO> _connections = new();

public void AddConnection(string connectionId, UserChatHubDTO user)
{

_connections[connectionId] = user;
}

public void RemoveConnection(string connectionId)
{
_connections.TryRemove(connectionId, out _);
}

public IEnumerable<string> GetConnectionIds(string anonymousUserId)
{
// To implement
return [];
}
}
public class UserChatHubDTO
{
public string UserId { get; set; }
public string Username { get; set; }
public UserChatHubDTO(string userId, string username)
{
UserId = userId;
Username = username;
}
}

public interface IConnectionManager
{
void AddConnection(string connectionId, UserChatHubDTO user);
void RemoveConnection(string connectionId);
IEnumerable<string> GetConnectionIds(string anonymousUserId);
}

public class ConnectionManager : IConnectionManager
{
private readonly ConcurrentDictionary<string, UserChatHubDTO> _connections = new();

public void AddConnection(string connectionId, UserChatHubDTO user)
{

_connections[connectionId] = user;
}

public void RemoveConnection(string connectionId)
{
_connections.TryRemove(connectionId, out _);
}

public IEnumerable<string> GetConnectionIds(string anonymousUserId)
{
// To implement
return [];
}
}
public class UserChatHubDTO
{
public string UserId { get; set; }
public string Username { get; set; }
public UserChatHubDTO(string userId, string username)
{
UserId = userId;
Username = username;
}
}

7 replies