signalr-hub

SignalR: Error during negotiation request: undefined

有些话、适合烂在心里 提交于 2019-11-29 15:27:52
I've been trying to get a javascript signal-r client working against a self-hosted owin server. And am running into this issue. I've tried both proxies and no proxy methods both with the same result of the and error "SignalR: Error during negotiation request: undefined". I've been able to get the cross-domain sample to run without any issues and cannot figure out what I am doing wrong, anyone have any ideas? The browser console gets logs an attempt to negotiate then I get the failure. Server/Hub namespace SignalROwinHost { class Program { static void Main(string[] args) { string url = "http:/

SignalR JS Client Methods Not Invoked

蓝咒 提交于 2019-11-29 13:54:29
I'm having trouble getting SignalR server-side Hub code to invoke JS client methods. The reverse is working fine - so when my client sends a message to the server it is delivered as expected. I've been fairly careful to avoid obvious traps but I guess I'm still overlooking something. Here's my code: From MessageHub.cs: public bool SendMessage( ClientMessage message ) { ... Clients.All.addMessage("my message"); ... } Javascript: $.connection.hub.start() .done(function () { messageHub = $.connection.message; // addMessage is never invoked. messageHub.client.addMessage = function (message) {

SignalR - Checking if a user is still connected

余生长醉 提交于 2019-11-29 13:16:16
问题 I have a hub with method that is called client-side. This method launches a timer with a delegate that runs every 10 seconds. Since it wouldn't make sense to keep running this delegate if no one is connected to the hub, I want to check if any users are still connected from inside the delegate before I reschedule it. Is there any way to do this? 回答1: Probably the most used solution is to keep a static variable containing users currently connected and overriding OnConnect and OnDisconnect or

signalR - getting username

五迷三道 提交于 2019-11-29 02:52:44
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 stepping through with the debugger, I found that HttpContext.Current.User.Identity.Name is null even though

SignalR: How to call .Net client method from server?

纵然是瞬间 提交于 2019-11-29 02:29:33
I want to send data to my console application wich have a connection to my "someHub". I tried to do as described in example from a link but got no result. Server side code: [HubName("somehub")] public class SomeHub : Hub { public override Task OnConnected() { //Here I want to send "hello" on my sonsole application Clients.Caller.sendSomeData("hello"); return base.OnConnected(); } } Clien side code: public class Provider { protected HubConnection Connection; private IHubProxy _someHub; public Provider() { Connection = new HubConnection("http://localhost:4702/"); _someHub = Connection

SignalR exception logging?

萝らか妹 提交于 2019-11-29 02:18:28
问题 This is more of two questions, but : What's the best way to have a top level exception handler for my Hub? It doesn't seem possible with the current version of SignalR Why doesn't this actually do anything on the client when I throw an error in my Hub? $.connection.hub.error(function() { return alert("test"); }); When I debug, I can see my error method being wired up, but when I throw an exception on the Hub, I can see there's never any attempt to call the method I setup above. The only thing

SignalR - Broadcasting over a Hub in another Project from outside of a Hub

大憨熊 提交于 2019-11-29 02:10:47
I have two projects in my solution: Project 1: "SignalRChat" (MVC) - Works fine Project 2: "DatabaseWatcherService" Windows Service - Works fine I'm trying to make a call to my SignalRChat Hub from my Windows Service and it doesn't appear to be working. This is where I call my Hub from my windows service ( https://github.com/SignalR/SignalR/wiki/Hubs#broadcasting-over-a-hub-from-outside-of-a-hub ): void PerformTimerOperation(object sender, EventArgs e) { eventLog1.WriteEntry("Timer ticked..."); var message = "test"; var context = GlobalHost.ConnectionManager.GetHubContext<SignalRChat.ChatHub>(

Use Hub methods from controller?

本小妞迷上赌 提交于 2019-11-29 01:22:54
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 public static void ClientSideMethod(param) inside my hub and in that method I use the IHubContext from the

SignalR cannot read property client of undefined

为君一笑 提交于 2019-11-28 17:45:32
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 runAllManagedModulesForAllRequests="true"/> to Web.Config 5) Created folder Hubs in the root of the MVC application 6

SignalR OnDisconnected - a reliable way to handle “User is Online” for chatroom?

烂漫一生 提交于 2019-11-28 17:02:57
I'm implementing a chat room. So far, so good - users can send messages from their browsers via a JS client, and I can use a C# client to do the same thing - these messages get broadcast to other users. Now, I'm trying to implement "online users". My approach is the following: OnConnected - update the User in the db to be IsOnline = true OnDisconnected - if the User doesn't have any other connections, update the user in the db to be IsOnline = false I'm storing state in the DB because I have to query the db for user thumbnails anyways - this seemed like a simple alternative to working with the