signalr

OnConnected method not called SignalR when I use shared connection in multiple hubs

我是研究僧i 提交于 2019-12-10 15:26:54
问题 We can create multiple hubs for different things, and to connect to each hub we can create multiple client side hubs with sharing connection so that, one connection being made to all hubs. Now, the problem arises that the hub onconnected method is not raising on each hub server side code. public class Hub1 : Hub { public override Task OnConnected() { return base.OnConnected(); } } public class Hub2 : Hub { public override Task OnConnected() { return base.OnConnected(); } } let say, on the

SignalR - HubContext and Hub.Context

╄→гoц情女王★ 提交于 2019-12-10 15:11:26
问题 I am new to signalR and reading the API and playing around with it. a bit confused about the Hub and its Context. That is, Hub.Context is not HubContext . HubContext I can get from GlobalHost.ConnectionManager.GetHubContext<THub>() and Hub.Context gives me a HubCallerContext which I am not sure how to use. What are their relationship? How can I get HubContext from Hub or Hub from HubContext ? 回答1: A result of poor naming. Hub.Context is the HTTP context from the caller (more like a request

SignalR continuous messaging

江枫思渺然 提交于 2019-12-10 15:05:34
问题 I have a web project which requires stats/logs on a web page to be updated from an external soap service. The approach I have decided to take with this is to use signalR, by having code that would execute a service method and return the results to all connected clients. This code will be continuously executed, with a delay between service calls. I am having trouble putting all of the pieces together, probably because I am not sure where everything should go! Here is a rough breakdown at what

XMPP Bosh vs SignalR

丶灬走出姿态 提交于 2019-12-10 15:04:06
问题 Does XMPP has more advantaces agains SignalR? They both using http long polling mechanism and I can not decide shall I use XMPP for my chat aplication or shall I use SignalR and keep everything ion my IIS server? 回答1: SignalR uses several transports see the explanation here How SignalR works internally?. Advantages of XMPP are the fact that greater number of other clients that just work out of the box (gchat, pidgin etc). But you could use both for your application if you wanted. 回答2: SignalR

Why is HTTPContext.Current.Session null using SignalR 2.x libraries in a ASP .Net MVC application?

爱⌒轻易说出口 提交于 2019-12-10 14:55:28
问题 I'm attempting to migrate our ASP.Net MVC application from using Signal R1.x tgo SignalR 2.x. I just found issue which will certainly cause us problems in our quest to move forward. Our web application is MVC based and makes heavy use of the HttpContext.Current.Session variable. When running with SignalR 1.x, everything is fine and dandy with Session. When we upgraded to SignalR 2.x, Session was suddenly null. I did a little googling and found the following links regarding the issue:

I am getting an undefined connection id in signalr javascript client

邮差的信 提交于 2019-12-10 14:47:36
问题 According to all documentation that i have come across i should be able to call $.connection.hub.id AFTER my connection has been started. this is my code: var handshake = $.connection.handshakeHub; $.connection.hub.start().done(function () { console.dir($.connection.hub); console.log('connection started with id: ' + $.connection.hub.id); self.parentConnectionId = document.cookie.replace(/(?:(?:^|.*;\s*)connection\s*\=\s*([^;]*).*$)|^.*$/, "$1"); handshake.server.connect(self

How to use SignalR with cross domain

 ̄綄美尐妖づ 提交于 2019-12-10 14:12:02
问题 I am trying to use SignalR with cross domain but i am getting error message when calling start function. Error message is "Uncaught TypeError: Cannot call method 'start' of undefined " I am using code Server side: [assembly: OwinStartup(typeof(SignalRChat.Startup))] namespace SignalRChat { public class Startup { public void Configuration(IAppBuilder app) { app.Map("/signalr", map => { map.UseCors(CorsOptions.AllowAll); var hubConfiguration = new HubConfiguration { EnableJSONP = true }; map

Implementing Authorization in a Self Hosted SignalR Server accessed from Web

女生的网名这么多〃 提交于 2019-12-10 13:58:57
问题 I'm looking for some guidance on how to implement authorization security for SignalR on a back end service running in a self-hosted (non-IIS) environment, that is called from a Web application. The backend app is basically a monitor that fires SignalR events back to the HTML based client. This all works fine (amazingly well actually). However, we need to restrict access to the server for authenticated users from the Web site. So basically if a user is authenticated on the Web site, we need to

How use UrlHelper in signalR HubClass

眉间皱痕 提交于 2019-12-10 13:58:20
问题 I have a Chat class drived from Hub. I want to know if thers a way to built URL by URLHelper like : Url.Action("action","Controller"). as i can derived the class from 2 abstract classes (Hub, Controller) i dont know if thers other way to build complete URls and not Hard code. 回答1: I use this code in my Hub currently, I'm sure there is a better way to do this, but this works. Note: If you want a a fully qualified url, make sure you set the domain correctly (example.com). protected virtual

SignalR server --> client call not working

半世苍凉 提交于 2019-12-10 13:26:31
问题 I'm currently using SignalR to communicate between a server and multiple separate processes spawned by the server itself. Both Server & Client are coded in C#. I'm using SignalR 2.2.0.0 On the server side, I use OWIN to run the server. I am also using LightInject as an IoC container. Here is my code: public class AgentManagementStartup { public void ConfigurationOwin(IAppBuilder app, IAgentManagerDataStore dataStore) { var serializer = new JsonSerializer { PreserveReferencesHandling =