Click here to Skip to main content
15,891,687 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all, my API recieves notifications from a Postgresql database when certain events happen in the database server, as I stated in a previous question I would like to forward these notifications to the client. I've been told I need to use a separate server such as SignalR to achieve this. I've added the required SignalR bits in Startup to my API ( net Core API )
 app.UseEndpoints(endpoints =>
 {
    endpoints.MapHub<SignalHub>("/signalclient");
 });
// SignalHub inherits from Hub
// added this in ConfigureServices
services.AddSignalR();

// I get this via di in my Controller

IHubContext<SignalHub> hubContext

// I issue this call from my Controller action

this.hubContext.Clients.All.SendAsync("ReceivePostgresNotification",e);

// which seems to execute ok


So my question is ?, how do I subscribe to these notifications from my client ( primarily my web app ) I hope this makes sense

What I have tried:

Added the SignalR code to the API and googling until I'm blue in the face
Posted
Updated 5-Feb-23 11:00am

There is a tonne of information, examples, tutorials, etc on this subject. A quick Google Search[^] or YouTube search[^] will give you many options.

As an example, from the Youtube Search[^] above, here is a video that is similar to what you are trying to achieve: SignalR with Sql Table Dependency in Asp.Net Core - YouTube[^]
 
Share this answer
 
 
Share this answer
 
Comments
pkfox 5-Feb-23 16:35pm    
I have Dave but it doesn't explain how I subscribe to a server
Dave Kreskowiak 5-Feb-23 16:38pm    
Yes it does, under Add SignalR client code[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900