signalr-hub

SignalR calling client method from outside hub using GlobalHost.ConnectionManager.GetHubContext doesn't work. But calling from within the hub does

本小妞迷上赌 提交于 2019-11-27 17:51:29
I'm trying to call a client method from within a .net Web API controller action. Can I do this? The only post I can find that comes close to what I am looking to do is this one: SignalR + posting a message to a Hub via an action method In there a message is sent from within an asp.net MVC controller action using GlobalHost.ConnectionManager.GetHubContext. When I try that inside my Web API action no errors are thrown, but the method "methodInJavascript" is never invoked on the client side. Public ActionResult MyControllerMethod() { var context = GlobalHost.ConnectionManager.GetHubContext<MyHub>

signalR - getting username

杀马特。学长 韩版系。学妹 提交于 2019-11-27 17:10:06
问题 I am using signalr and asp.net MVC3 to build a sample chat application. Here is what my signalr hub looks like public class MyHub:Hub,IDisconnect { public Task Join() { string username = HttpContext.Current.User.Identity.Name; //find group based on username string group = getGroup(username) return Groups.Add(Context.ConnectionId, group); } public void doStuff() { string group = getGroup(); Clients[group].doStuffOnBrowser(); } } My problem is that my app crashed when the page loads. on

.net localhost website consistently making get arterySignalR/poll?transport=longPolling&connectionToken= calls

时光毁灭记忆、已成空白 提交于 2019-11-27 16:48:38
I created a new VS 2013 project and viewed the default.aspx page with the Firefox browser. When I check the net calls it has made, I see it making constant calls to: http://localhost:50682/6a663a78019845d5ade4a328cad09cc2/arterySignalR/poll?transport=longPolling&connectionToken=AQAAANCMnd8BFdERjHoAwE%2FCl%2BsBAAAAOBmDwPWa2ky2MAZXFHBMVAAAAAACAAAAAAAQZgAAAAEAACAAAADSADQXBVKiKczflJ0OzUjOLduFTJE4zd%2FLHWGpDfXnuAAAAAAOgAAAAAIAACAAAACyEX81VwilygfphPoEKCYQ6ZwrkzExoKfZzEMkqBKqqzAAAADG%2BDJbrEFOfsNm9OKhqacnGseQvrwy5kmyZnI5YJiZbjYFgzMELXHfwA7Sxjj4osJAAAAAvQvoG4N0nn8eB9FRaJaZyqaUDF%2F9ypvGN%2B

Use Hub methods from controller?

我的未来我决定 提交于 2019-11-27 15:53:38
问题 I am using SignalR 2 and I can not figure out how I can use my Hub methods e.g from inside a controller action. I know I can do the following: var hub = GlobalHost.ConnectionManager.GetHubContext<T>(); hub.Clients.All.clientSideMethod(param); But that executes the method directly on the client side. What if I have business logic inside my server side ClientSideMethod(param) method I want to call from my controller the same way as when it is called from the client side? At the moment I use

How do I send messages from server to client using SignalR Hubs

与世无争的帅哥 提交于 2019-11-27 13:02:54
问题 I am just starting to explore signalR and I would like to able to send messages from the server to all clients. Here is my Hub using System; using System.Collections.Generic; using System.Linq; using System.Web; using SignalR; using SignalR.Hubs; using SignalR.Hosting.Common; using SignalR.Hosting.AspNet; using System.Threading.Tasks; namespace MvcApplication1 { public class Chat : Hub { public void Send(String message) { // Call the addMessage methods on all clients Clients.addMessage

How to use SignalR hub instance outside of the hubpipleline

风流意气都作罢 提交于 2019-11-27 11:24:36
I am using SignalR to broadcast messages to all my clients. I need to trigger the broadcasting outside of my hub class i.e. something like below: var broadcast = new chatHub(); broadcast.Send("Admin","stop the chat"); I am getting error message as: Using a Hub instance not created by the HubPipeline is unsupported. You need to use GetHubContext : var context = GlobalHost.ConnectionManager.GetHubContext<chatHub>(); context.Clients.All.Send("Admin", "stop the chat"); This is described in more detail at http://www.asp.net/signalr/overview/signalr-20/hubs-api/hubs-api-guide-server

SignalR cannot read property client of undefined

不打扰是莪最后的温柔 提交于 2019-11-27 10:42:17
问题 I'm trying to add SignalR to my project (ASPNET MVC 4). But I can't make it work. In the below image you can see the error I'm receiving. I've read a lot of stackoverflow posts but none of them is resolving my issue. This is what I did so far: 1) Ran Install-Package Microsoft.AspNet.SignalR -Pre 2) Added RouteTable.Routes.MapHubs(); in Global.asax.cs Application_Start() 3) If I go to http://localhost:9096/Gdp.IServer.Web/signalr/hubs I can see the file content 4) Added <modules

SignalR doesn't use Session on server

倾然丶 夕夏残阳落幕 提交于 2019-11-27 08:49:46
When I try to access the HttpContext current session from the HUB it returns null . I tried making use of the interface IRequiresSession but it didn't work. Can someone help me? Damian Edwards 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 request will block the other e.g. in the long polling

When does a reconnect in signalR occur?

若如初见. 提交于 2019-11-27 04:59:41
问题 I've started working with SignalR and was trying to figure out when a Hub Reconnect occurs. I didn't find any satisfying explanation on the web. Can someone explain when/why a reconnect occurs? 回答1: A hub reconnect occurs when a client goes offline then regains connectivity shortly after. SignalR configuration values largely determine the time stamps of the following examples so do not take the times verbatim. Here are several examples and their outcomes (time format m:ss) involving

Best practice for reconnecting SignalR 2.0 .NET client to server hub

前提是你 提交于 2019-11-27 04:58:16
问题 I'm using SignalR 2.0 with the .NET client in a mobile application which needs to handle various types of disconnects. Sometimes the SignalR client reconnects automatically - and sometimes it has to be reconnected directly by calling HubConnection.Start() again. Since SignalR magically auto-reconnects some of the time, I'm wondering if I'm missing a feature or config setting? What's the best way to set up a client that reconnects automatically? I've seen javascript examples that handle the