using SignalR you can do server-to-client and client-to-server streaming separately. Is it possible to do it both ways simultaneously?
Suppose we have some sensor data coming from and IoT device, and as soon as we receive it on the server we want to broadcast it to other devices. Using IAsyncEnumerable how can it be done?
Server-to-client Hub:
public async IAsyncEnumerable<string> GetTempData()
{
while (true)
{
await Task.Delay(1000);
yield return DateTime.Now.Second.ToString();
}
}
client-to-server
public async Task SendTempData(IAsyncEnumerable<string> lines)
{
await foreach (var line in lines)
{
await Clients.Others.SendAsync("GetData", line);
}
}
as you can see I'm currently using SendAsync but want to replace it with streams. I don't know how to pass data SendTempData to GetData here.
I found out that SignalR doesn't have Bidirectional Streaming, to do that you need to use other techniques like gRPC.