Skip to content

Streaming IObservable<T> to specific client and not all connected clients. #2263

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sabinayakc opened this issue Oct 31, 2017 · 1 comment
Closed

Comments

@sabinayakc
Copy link

sabinayakc commented Oct 31, 2017

Hello,

I would like to know if there's a way to Stream an IObservable to a specific client. The StockTickr example shows a way to Stream stocks but it is streaming for all connected clients. Can we stream different data depending on the connected client's request?

  public IObservable<Stock> StreamStocks()
  {
       return _stockTicker.StreamStocks();       
  }

StockTickr Example

@BrennanConroy
Copy link
Member

BrennanConroy commented Oct 31, 2017

Sure, if you take a look at this sample:
https://github.com/aspnet/SignalR/blob/83bb07d5a4282a7486d5ef426f53633db1f083ae/samples/SocketsSample/Hubs/Streaming.cs#L11-L16
Every time the Hub method is called a new observable is created. The stock ticker just caches its stream for obvious reasons, but you aren't limited to that.

Also, SignalR issues should go to the SignalR repo https://github.com/aspnet/SignalR/issues

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants