diff --git a/aspnetcore/signalr/streaming.md b/aspnetcore/signalr/streaming.md index b4f90c47f2..40e8dfdb78 100644 --- a/aspnetcore/signalr/streaming.md +++ b/aspnetcore/signalr/streaming.md @@ -5,7 +5,7 @@ description: Learn how to stream data between the client and the server. monikerRange: '>= aspnetcore-2.1' ms.author: bradyg ms.custom: mvc, devx-track-js -ms.date: 11/12/2019 +ms.date: 10/29/2020 no-loc: [appsettings.json, "ASP.NET Core Identity", cookie, Cookie, Blazor, "Blazor Server", "Blazor WebAssembly", "Identity", "Let's Encrypt", Razor, SignalR] uid: signalr/streaming --- @@ -304,6 +304,22 @@ hubConnection.stream(String.class, "ExampleStreamingHubMethod", "Arg1") The `stream` method on `HubConnection` returns an Observable of the stream item type. The Observable type's `subscribe` method is where `onNext`, `onError` and `onCompleted` handlers are defined. +### Client-to-server streaming + +The SignalR Java client can call client-to-server streaming methods on hubs by passing in an [Observable](https://rxjs-dev.firebaseapp.com/api/index/class/Observable) as an argument to `send`, `invoke`, or `stream`, depending on the hub method invoked. + +```java +ReplaySubject stream = ReplaySubject.create(); +hubConnection.send("UploadStream", stream); +stream.onNext("FirstItem"); +stream.onNext("SecondItem"); +stream.onComplete(); +``` + +Calling `stream.onNext(item)` with an item writes the item to the stream, and the hub method receives the item on the server. + +To end the stream, call `stream.onComplete()`. + ::: moniker-end ## Additional resources