Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add StreamingHub OnConnected support #745

Merged
merged 1 commit into from
Mar 21, 2024

Conversation

riversdark0
Copy link

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.

@mayuki
Copy link
Member

mayuki commented Mar 21, 2024

Thank you for your contribution! It looks good to me.

@mayuki mayuki merged commit 015e5a0 into Cysharp:main Mar 21, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants