I am facing an issue in my application where clients are not receiving messages from the Hub when a user signs in.
Here is my Hub class:
public class GameHub : Hub
{
public async Task UserLoggedIn(string userName)
{
await Clients.All.SendAsync("UserLoggedIn", userName);
}
}
The UserLoggedIn
method on GameHub
gets called when a user logs in as I have set a breakpoint and verified it.
On the client page, I have:
const connection = new signalR.HubConnectionBuilder()
.withUrl("/gameHub")
.configureLogging(signalR.LogLevel.Information)
.build();
connection.start().then(() => {
console.log("connected");
});
connection.on("UserLoggedIn", (userName) => {
console.log("User Logged In" + userName);
});
Even though the console window in another incognito browser shows "connected," I do not see "User Logged In" after the UserLoggedIn
method is invoked on GameHub
.
Could someone help me identify what could be causing this issue?