signalr-hub

How to dynamically add hub to SignalR and have different scopes

点点圈 提交于 2019-12-05 04:21:28
问题 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

SignalR Join Group From Controller

你离开我真会死。 提交于 2019-12-04 20:08:44
When the user logs in on my site, they select from a dropdown which group they belong to. On the login postback, as they are logged in, I'd like to assign them to the correct SignalR group. As per the documentation here , I can join it client-side via: contosoChatHubProxy.server.joinGroup(groupName); Is there a way to assign the group from the controller? I can call the Hub like: var hub = new NotificationHub() hub.JoinGroup(selectedGroup); but the Context in the hub method is null. Is this possible, or am I approaching this problem incorrectly? Thankyou for any advice. You shouldn't new up a

SignalR hub method parameter serialization

大兔子大兔子 提交于 2019-12-04 17:11:31
问题 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

SignalR: Hub OnConnected not called if no client methods

。_饼干妹妹 提交于 2019-12-04 17:09:45
问题 I am writing a game in SignalR. The idea is that you connect with your laptop, which will be used as "display" and then you connect with your smart phone and that will be used as "joystick". The entire setup works very well. Now that it all works, I decided to refactor the code. I realized that the relationship between the joystick and the display is one way (the display never needs to send information back to the joystick). Therefore I decided that I did not need any signalR invokable client

SignalR: How to stop creating new connection on page reload

本小妞迷上赌 提交于 2019-12-04 14:45:32
Hi i am developing a chat application along with some other pages in my application. once i login i am maintaining the session of the user. My main intention is that user should get notification whenever another user connects to server. The problem that i am facing is whenever i navigate to some other page in my application the connection is lost. How to stop this behaviour and continue the connection until user logs out. I am using SignalR 2.0 in ASP.NET MVC4 project, any help?? Each connection only has a lifecycle for the duration of the time the user spends on a given page. When they

SignalR on Xamarin.iOS - randomly not able to call Hub method

拈花ヽ惹草 提交于 2019-12-04 14:26:34
I have a simple Hub running in Azure, that I have working perfectly from a console app in Windows. I just built a simple test Xamarin.iOS app, and it is giving some strange behavior. Randomly on LTE/Wifi or Simulator/Device - invoking a hub method fails with There was an error invoking Hub method X Randomly about 50% - everything works perfectly just like the console app on Windows - the two are even sending messages to one another I tested this on an iPhone 5S and iPhone 4S for devices. Any ideas on why this would happen? I'm using the Portable NuGet package on version 2.0.0. UPDATE: Here is

SignalR Client How to Set user when start connection?

喜欢而已 提交于 2019-12-04 11:20:49
问题 Server side: public override Task OnConnected() { var connectionId = Context.ConnectionId; var user = Context.User.Identity.Name; // Context.User is NULL return base.OnConnected(); } Client side (in Console project): IHubProxy _hub; string url = @"http://localhost:8080/"; var connection = new HubConnection(url); _hub = connection.CreateHubProxy("TestHub"); connection.Start().Wait(); When the client connect to the server, I want to know the map between userName and connectionId, But Context

Can I reduce the Circular Buffer to “1”? Is that a good idea?

大兔子大兔子 提交于 2019-12-04 10:07:44
By default, there are a default of 1,000 messages stored in the ring buffer on the server. It doesn't make sense for me to send a lagging client 1,000 updates, but rather just the most recent update. In WCF I can do this by using volatile data. I suppose I can emulate a volatile approach by reducing the buffer to "1", but not sure if this can be configured on a per hub basis, or ideally, on a per method basis. Does it matter if I use hubs or persistent connections with this? Even if you set the DefaultMessageBufferSize to 1, SignalR ensures each buffer will hold at least 32 messages. The

Angular : Unable to pass API url in SignalR HubConnection

只谈情不闲聊 提交于 2019-12-04 09:34:16
I have developed a project in Angular6. There is a requirement to develop section for live chat. For that I am using SignalR in my asp.net core Web Apiproject. Now I want to use this Web Api reference in my Angular project. I am using this link. But while providing the Web Api url in App.Component.ts, I am getting below error : Constructor of class 'HubConnection' is private and only accessible within the class declaration. App Component.ts : import { HubConnection } from '@aspnet/signalr'; import { Message } from 'primeng/api'; export class AppComponent implements OnInit { public

SignalR Hub Overloads

假装没事ソ 提交于 2019-12-04 04:03:41
I tried creating a basic hub with two Receive methods, one accepts a string and the other an int. This causes an error stating that the method cannot be resolved. Commenting out one of the methods gets rid of the error and everything works. Is it possible to have overloads of a method in my hub? Could something like overloads be done? SignalR does support overloading server-side Hub methods, but the overloads must have a different arity, i.e. take a different number of arguments. If the overloads have the same arity, SignalR will be unable to resolve which overload is being called, even though