In my project, I need send current game state to the client after the client connect or reconnect to the hub without client call the server, I tried overriding the StreamingHubBase.OnConnecting method, then send game state to the client in this method, but sometimes the following exception is thrown:
System.InvalidOperationException: Response headers can only be sent once per call.
at Grpc.AspNetCore.Server.Internal.HttpContextServerCallContext.WriteResponseHeadersAsyncCore(Metadata responseHeaders)
at Grpc.Core.ServerCallContext.WriteResponseHeadersAsync(Metadata responseHeaders)
at MagicOnion.Server.Hubs.StreamingHubBase`2.HandleMessageAsync() in ./MagicOnion.Server/Hubs/StreamingHub.cs:line 164
So I think need add an OnConnected method and call it after sending headers and marker.
In my project, I need send current game state to the client after the client connect or reconnect to the hub without client call the server, I tried overriding the StreamingHubBase.OnConnecting method, then send game state to the client in this method, but sometimes the following exception is thrown:
So I think need add an OnConnected method and call it after sending headers and marker.