Initial Client/Server Communication
#1 Followed the MagicOnion quickstart guide, borrowing code from the chat sample app to get something working
This commit is contained in:
parent
52b0d4d8ff
commit
a0c8dbee72
493 changed files with 57790 additions and 3 deletions
|
|
@ -0,0 +1,80 @@
|
|||
using Grpc.Core;
|
||||
using MessagePack;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagicOnion
|
||||
{
|
||||
/// <summary>
|
||||
/// Wrapped AsyncServerStreamingCall.
|
||||
/// </summary>
|
||||
public struct ServerStreamingResult<TResponse> : IDisposable
|
||||
{
|
||||
readonly AsyncServerStreamingCall<byte[]> inner;
|
||||
readonly IAsyncStreamReader<TResponse> responseStream;
|
||||
|
||||
public ServerStreamingResult(AsyncServerStreamingCall<byte[]> inner, IAsyncStreamReader<TResponse> responseStream, MessagePackSerializerOptions serializerOptions)
|
||||
{
|
||||
this.inner = inner;
|
||||
this.responseStream = responseStream;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Async stream to read streaming responses.
|
||||
/// </summary>
|
||||
public IAsyncStreamReader<TResponse> ResponseStream
|
||||
{
|
||||
get
|
||||
{
|
||||
return responseStream;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Asynchronous access to response headers.
|
||||
/// </summary>
|
||||
public Task<Metadata> ResponseHeadersAsync
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.inner.ResponseHeadersAsync;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the call status if the call has already finished.
|
||||
/// Throws InvalidOperationException otherwise.
|
||||
/// </summary>
|
||||
public Status GetStatus()
|
||||
{
|
||||
return this.inner.GetStatus();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the call trailing metadata if the call has already finished.
|
||||
/// Throws InvalidOperationException otherwise.
|
||||
/// </summary>
|
||||
public Metadata GetTrailers()
|
||||
{
|
||||
return this.inner.GetTrailers();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Provides means to cleanup after the call.
|
||||
/// If the call has already finished normally (response stream has been fully read), doesn't do anything.
|
||||
/// Otherwise, requests cancellation of the call which should terminate all pending async operations associated with the call.
|
||||
/// As a result, all resources being used by the call should be released eventually.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Normally, there is no need for you to dispose the call unless you want to utilize the
|
||||
/// "Cancel" semantics of invoking <c>Dispose</c>.
|
||||
/// </remarks>
|
||||
public void Dispose()
|
||||
{
|
||||
if (this.inner != null)
|
||||
{
|
||||
this.inner.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue