In my SignalR Hub (.NET 5) i want to override the OnConnectedAsync method to read the request headers that the client sent using:
public override Task OnConnectedAsync() {
var username = Context.GetHttpContext().Request.Headers["username"];
return base.OnConnectedAsync();
}
How do i build the connection to my hub using the @microsoft/signalr client library? Currently my connection looks like this:
var connection = new signalR.HubConnectionBuilder()
.withUrl("/game")
// Add username header to connection
.build();
If I am using the wrong strategy on my server hub, how else would i try to do this?