signalr-hub

How to send a message to specific user using aspnetcore signalR?

两盒软妹~` 提交于 2020-04-17 22:52:28
问题 I have a requirement to send notification to specific user. I am using dotnet core 3.1. ASPNETCORE signalR for the notification. I am able to send the messages to all clients but unablt to do so for specific user. EDIT 1 My Hub looks like : public class NotificationHub : Hub { public override async Task OnConnectedAsync() { await Groups.AddToGroupAsync(Context.ConnectionId, Context.User.Identity.Name); await base.OnConnectedAsync(); } public override async Task OnDisconnectedAsync(Exception

Sending complex objects from signalR .NET Core 3.0 hub to clientIn

筅森魡賤 提交于 2020-01-25 00:27:30
问题 This should be a simple question. I am trying to send complex objects to a client by id from a SignalR Hub. However, I can seem to find any examples that work with .NET Core 3.0. Do I need to serialize it and call Clients.Client(id).BroadcastMessage("method",jsonString); ? or is there a better way to do this? 回答1: Note: This is tested only on ASP.NET Core 3.1 and may/may not work on older versions. You can pass multiple objects from C# and then receive them all in a Typescript function with a

Is calling a SignalR Hub from the Application Service Layer a bad practice in ASP.Net Boilerplate?

こ雲淡風輕ζ 提交于 2020-01-24 09:33:26
问题 I'm using the Asp.Net boilerplate template with ASP.Net Core 2.1. I implemented a Hub in the Web.Core assembly and created a controller. I can subcribe/notify data with my hub from any client, this is not my problem. I'd like to use this Hub in the Application Services layer, but SignalR is not referenced by Application Services layer by default. So my question is : Is it a bad practice to reference SignalR in the the Application Services layer ? Thanks in advance ! Regards, Pierre-Luc 回答1:

How can I listen postgresql database with SignalR Core in .net core project?

。_饼干妹妹 提交于 2020-01-22 16:35:08
问题 I'm working on .net core web application. I want to listen my PostgreSQL database. And if there are any changes on table, I have to got it. So according to my research, I have to use SignalR Core. I did some example application with SignalR like chat app but none of them listen database. I couldn't find any example for this. -Does It have to be trigger on PostgreSQL database? -Does It have to be listener on code side? -How can I use SignalR Core? Please show me a way. Thanks a lot. 回答1: This

Access DB context through SignalR Core

女生的网名这么多〃 提交于 2020-01-21 09:19:25
问题 I'm using AspNetCore.SignalR and I need advice on how to access my SQL Server database through my Hub. There are not a lot of resources out there about this. I know how to add a singleton but I do not know how to access it later. How can I access a DB context that is defined using a Configuration.GetConnectionString in Startup.cs inside my Hub's Tasks? Thanks. Here's the relevant code: Startup.cs public void ConfigureServices(IServiceCollection services) { services.Configure

SignalR IE9 Cross Domain request don't work

情到浓时终转凉″ 提交于 2020-01-16 05:33:08
问题 I'm making an application using SignalR. The Hub is placed on one server running Windows Server 2012 with IIS 8. http://mentor.cloudapp.net/mass/rexona/previa/signalr/hubs. The client is here: http://massdeveloperstage.com/Rexona/Site/colombia/Previa/Match?matchId=6F318A29-3400-444B-95D9-7EC41A7AD2D4 The Signalr set up looks like this: var match; $(document).ready(function () { $.connection.hub.loging = true; match = $.connection.match; match.client.addMessage = function (message) { var vm =

SignalR hubclass in classlibrary

血红的双手。 提交于 2020-01-16 01:55:08
问题 I have a signalr hubclass in a classlibrary and when i use that hubclass in my webapplication referencing that class library with below javascript code, it does not work, $(function () { var chat = $.connection.notificationHub; chat.client.newMessage = function (message) { alert(message); $('#messages').append('<li><strong>' + message + '</strong>: </li>'); }; $.connection.hub.start(); }); 回答1: You need an event to trigger your method in Hub class. See below example: NotificationHub in the

SignalR - Javascript Hub Proxies

♀尐吖头ヾ 提交于 2020-01-14 06:32:23
问题 When you use SignalR, in your HTML you need to reference the following two scripts: <script src="~/Scripts/jquery.signalR-1.0.0.js"></script> <script src="/signalR/hubs"></script> The second one is for a JavaScript hub proxy which will be auto generated. Everything works fine. However what happens if the JavaScript Hub Proxy generation is disabled somehow, perhaps by setting DisableJavaScriptProxies property (https://github.com/SignalR/SignalR/commit/7e974f4e92551a26f3e3e0a166e1dbf6c064e850).

SignalR cross-domain connection - connecting connection Id's with users

此生再无相见时 提交于 2020-01-14 05:57:10
问题 I'm hosting my signalr hub on a separate domain and making cross domain connection to hub from my main application. When a user logs into the main application, signalr connection is established. Now, the problem I'm having is how to identify the connected user inside the hub. If my Hub was within the main application then I could use the Context.User of the logged in user and maintain a dictionary and update them on Connect and Disconnect events. But being a cross-domain connection, I don't

SignalR Broadcast Intercept Using Pipeline Module

人走茶凉 提交于 2020-01-14 02:34:08
问题 I have created a setup where I have a back-end service that is broadcasting messages using SignalR through a SQL backplane and clients are receiving the messages through a MVC 5 + SignalR web application on a web farm. I want to intercept the messages before they get to the client from the web application and make some changes to the message, specifically return HTML to the client instead of the raw data. I have been able to achieve this in a development environment where the messages