signalr-hub

SignalR overwriting OnConnected(), OnDisconnected()

心不动则不痛 提交于 2019-12-04 03:55:54
I'm trying to overwrite OnConnected(), OnDisconnected() methods but I get: OnConnected()': no suitable method found to override Is implementing IDisconnect, IConnect interfaces and doing my processing within Connect() and Disconnect() the same as OnConnected(), OnDisconnected()? what gives? public static class UserHandler { public static HashSet<string> ConnectedIds = new HashSet<string>(); } public class MyHub : Hub { public override Task OnConnected() { UserHandler.ConnectedIds.Add(Context.ConnectionId); return base.OnConnected(); } public override Task OnDisconnected() { UserHandler

SignalR - Send message OnConnected

断了今生、忘了曾经 提交于 2019-12-04 03:34:16
I've been experimenting with SignalR today and It's really neat. Basically what I wanted to achieve is the following: As soon as a device connects it should send a message to the first one. If there are more devices than 1 connected I would like to send two messages. One to all except the last connected client. And one message to only the last connected client. The code I've been using works perfect when I place it in a custom API controller and basically call the action, but that's not what I want. I would like to send the messages as soon as a device connects within OnConnected without any

SignalR: Error loading hubs

↘锁芯ラ 提交于 2019-12-04 02:02:00
Signalr doesn't load my hubs: SignalR: Error loading hubs. Ensure your hubs reference is correct, e.g. <script src='/signalr/js'></script>. I am calling app.MapSignalR(); in startup configuration . I added to my cshtml: <script src="~/Scripts/jquery-1.9.1.js"></script> <script src="~/Scripts/jquery.signalR-2.0.0.js"></script> <script src="~/signalr/hubs" type="text/javascript"></script> <script> $(document).ready(function () { window.hubReady = $.connection.hub.start(); }); </script> Make sure your startup class has this attribute: [assembly: OwinStartup(typeof(MyStartupClass))] You can define

Signalr Hub in Separate Dll

↘锁芯ラ 提交于 2019-12-04 01:46:38
问题 I had a hub hosted in a console app with a WPF app connecting to it. It worked just fine. Then I moved the hub into a separate project and added a reference from the host to new project. Now I am getting a 500 error, with no other details. Is there anything different that needs to be done in order to host a hub from another assemble/namespace? Edit: I tried a few things after opening the question. Here is what I have tried so far: Setting the HubName attribute. - Did not work. Passing the

How to dynamically add hub to SignalR and have different scopes

馋奶兔 提交于 2019-12-03 17:09:32
I'm attempting to build a Dashboard with widgets (built as directives). I'd like to at a later stage have the ability to dynamically add widgets, but I'd only like the active widgets (and hubs) to receive data, thus if a widget isn't active i don't want the hub to be registered. Eg for the duration of the user using the app there will be a global signalR context, as well as page specific ones, which will be spawned/destroyed as needed. This is my best try ATM... which isn't working factory (function () { 'use strict'; angular.module('app').factory('hubFactory', ['permissionSvc', 'common',

Cross origin SignalR connection stops after negotiate

我怕爱的太早我们不能终老 提交于 2019-12-03 14:12:28
I have an MVC 5 app serving up views, and a Web API 2 app as the service layer (.NET 4.5). The Web API app uses SignalR 2.1.2 to return progress as it's processing POSTs to the service API. The two are deployed to different domains, so I've set up cross origin support as per the asp.net tutorial article. [assembly: OwinStartup(typeof (Startup))] namespace MyApp.Service { public class Startup { public void Configuration(IAppBuilder app) { app.Map("/signalr", map => { //worry about locking it down to specific origin later map.UseCors(CorsOptions.AllowAll); map.RunSignalR(new HubConfiguration());

Passing strongly typed Hubs in SignalR

你说的曾经没有我的故事 提交于 2019-12-03 11:17:58
I've just updated some SignalR references and things have changed somewhat in order to allow for generically typed Hubs Hub<T> . In the existing examples and documentation such as at: Server-Broadcast-with-Signalr we have a static class holding references to clients via the following mechanisms: public class StockTicker() { private readonly static Lazy<StockTicker> _instance = new Lazy<StockTicker>( () => new StockTicker(GlobalHost.ConnectionManager.GetHubContext<StockTickerHub>().Clients)); IHubConnectionContext Clients {get;set;} private StockTicker(IHubConnectionContext clients) { Clients =

SignalR hub method parameter serialization

谁说胖子不能爱 提交于 2019-12-03 10:25:46
I would need some guidelines from SignalR developers what is the best way to tweak HUB method's parameters serialization. I started migrating my project from WCF polling duplex (Silverlight 5 - ASP.NET 4.5) to SignalR (1.1.2). The message (data contract) is polymorphic based on interfaces. (Like IMessage, MessageA : IMessage, etc. - there is actually hierarchy of interfaces implemented by classes but it is not of much significancy for the question). (I know polymorphic objects are not good for clients but client will handle it as JSON and mapping to objects is done only on server side or

SignalR and HttpContext/Session

落爺英雄遲暮 提交于 2019-12-03 09:53:16
I understand why SignalR doesn't give you access to the HttpContext . However, this is quite problematic for us. Let me explain: Our application is a Multi-Tenant application where the user chooses the environment while logging in. This basically registers the ConnectionStringName in the HttpSession. In our SignalR Hub, we need to access the database on Disconnect . But this is not possible because we have no HttpContext at this point and cannot determine the environment to write to. Can anyone provide us with a suggestion how to solve this problem? We're a bit stuck on this one. EDIT : Bonus

SignalR & require.js configuration

こ雲淡風輕ζ 提交于 2019-12-03 08:27:52
问题 I'm incorporating SignalR into a project where I'm already using require.js to handle my scripts dependencies. I'm having a little trouble making sure "/signalr/hubs" is called after "jquery.signalR-1.1.2" loads. I got it to work, but I'm wondering if there is a better alternative out there. This is what I have: require(["signalr"], function () { require(["noext!/signalr/hubs"], function () { //initialize and work with the hub here } } Is there a way I can create a shim here to establish the