Есть ли хороший способ узнать, можно ли установить двунаправленный поток?
Код: Выделить всё
try
{
using var streamingCall = someService.CallBidirectionalStream(cancellationToken: cancellationToken);
// does not throw an exception, when the interface is not implemented (sometimes it does)
// it only reliably throws rpc exception, when server not started.
await streamingCall.RequestStream.WriteAsync(mapper.Map(currentData), cancellationToken)
.ConfigureAwait(false);
// should only run when connected
using subscription = await SetConnection(streamingCall, cancellationToken)
.ConfigureAwait(false);
// only this throws exception, when not implemented.
while (await streamingCall.ResponseStream.MoveNext(cancellationToken)
.ConfigureAwait(false))
{
var response = streamingCall.ResponseStream.Current;
ProcessResponse(response);
}
}
catch (OperationCanceledException)
{
}
catch (RpcException ex)
{
}
catch (Exception ex)
{
}
Подробнее здесь: https://stackoverflow.com/questions/798 ... mplemented
Мобильная версия