SignalR OnDisconnected – a reliable way to handle “User is Online” for chatroom?
Try following this sample here: https://github.com/DamianEdwards/NDCLondon2013/tree/master/UserPresence
Try following this sample here: https://github.com/DamianEdwards/NDCLondon2013/tree/master/UserPresence
SignalR connections (including the connection underlying all Hub operations for a client) do not support Session state. You could enable it if you wanted to but we’d strongly recommend against it as session state access serializes requests for a given client, meaning you won’t really get the benefit from SignalR duplex messaging anymore, as one … Read more
I came across with same issue couple days ago. That took my 2 days to find solution and resolve it. After some serious investigate the problems root cause was the signalr dependency resolver that I set customly. At the end I found this link and that was saying this: Replacing the DependencyResolver You can change … Read more
When using SignalR hubs you can use the HubCallerContext.User property to: Gets the user that was part of the initial http request. So try it with: public Task Join() { string username = Context.User.Identity.Name; //find group based on username string group = getGroup(username) return Groups.Add(Context.ConnectionId, group); }
Now is possible with Postman version > 8.0 using WebSocket Request block. You can grab the information in their blog post https://blog.postman.com/postman-supports-websocket-apis/
I’ve had a bit similar problem but with Unity instead of Castle Windsor. My requirements: I wanted to avoid singleton registrations on the container. All objects are resolved in Hub and should be disposed on Hub destruction. Registrations reused across Web Api and SignalR. Object lifetime is managed by HierarchicalLifetimeManager – child containers resolve and … Read more
There is no easy way to set HTTP headers for SignalR requests using the JS or .NET client, but you can add parameters to the query string that will be sent as part of each SignalR request: JS Client $.connection.hub.qs = { “token” : tokenValue }; $.connection.hub.start().done(function() { /* … */ }); .NET Client var … Read more
I found the final solution, this is the code of my OWIN startup class: public void Configuration(IAppBuilder app) { app.MapSignalR(); // Enable the application to use a cookie to store information for the signed i user app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie, LoginPath = new PathString(“/Home/Index”) }); // Use a cookie to temporarily store information … Read more
The correct way is to actually create the hub context. How and where you do that is up to you, here are two approachs: Create a static method in your hub (doesn’t have to be in your hub, could actually be anywhere) and then you can just call it via AdminHub.SendMessage(“wooo”) public static void SendMessage(string … Read more
IConnectionManager does not exist any more in SignalR for ASP.Net Core. I’ve been using HubContext for getting access to a hub. public class HomeController : Controller { private readonly IHubContext<LiveHub> _hubContext; public HomeController(IHubContext<LiveHub> hubContext) { _hubContext = hubContext; } public void SendToAll(string message) { _hubContext.Clients.All.InvokeAsync(“Send”, message); } } I’m using .net core 2.0.0 and SignalR … Read more