3

It is simple to send an special message type from server to some group of Clients in SignalR using:

 Client.Groups("Developers").SendAsync("Notification",new {Message="New Notification Arrived from ...."});

And Also it is not hard to send an stream from server to client. But it should pulled from client side as:

hubConnection.stream("CounterStream").subscribe({next:f1,complete:f2,error:f3})

Now I want to send an stream from server to group of user. A simple answer is to first send a notification to group of user and then they subscribe to stream but as you may know it is not very performant since the stream should be prepared for each client in server. How we can push the stream once from server to client and user invoke it?

Mehdi Mowlavi
  • 434
  • 1
  • 11
  • 1
    There is no built in way to do that, so you need to roll your own. One example implementation is at https://github.com/SignalR/sample-StreamR/blob/main/Hubs/StreamHub.cs (note, not production code) – Brennan Dec 12 '21 at 04:54
  • @Brennan Thanks. The code is clear enough. Is it my requirement okay with real situation ever? I mean, is it possible to handle sending a stream to multiple clients simultaneously by physical and network layers and protocols (beyond .NET and SignalR)? – Mehdi Mowlavi Dec 12 '21 at 19:41
  • 1
    @Brennan you got a nice implementation of it, but as you said, it is not production code. This feature was asked here: https://github.com/dotnet/aspnetcore/issues/10151 and as far as I understand it will be released with the .NET 7 version: https://github.com/dotnet/aspnetcore/issues/38196. So, in order to accomplish this and follow the current SignalR state of the art, I will need the conventional approach, right? – juan_marti Jan 17 '22 at 11:48

0 Answers0