Skip to content

fix: preventing issues with game code registering multiple ConnectionApprovalCallbacks [MTT-3496] #1972

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

Merged
merged 6 commits into from
May 17, 2022

Conversation

jeffreyrainy
Copy link
Contributor

fix: preventing issues with game code registering multiple ConnectionApprovalCallback. Refactored the entire connection approval

Changelog

  • [breaking] ConnectionApprovalCallback is now ConnectionApprovalHandler. Receives a ConnectionApprovalRequest, and returns a ConnectionApprovalResult. By virtue of being a Func<>, there cannot be multiple handlers registered.

  • Fixed issues when multiple Connection Approval callbacks were registered (Exception when there are multiple connectional approval callbacks #1941)

…ApprovalCallback. Refactored the entire connection approval
@jeffreyrainy jeffreyrainy requested a review from a team as a code owner May 16, 2022 21:32
@jeffreyrainy jeffreyrainy requested a review from 0xFA11 May 16, 2022 21:32
{
if (value != null && value.GetInvocationList().Length > 1)
{
Debug.LogError(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

throw an InvalidOperationException instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/instead/additionally ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

an unhandled exception is eventually an error/exception log in Unity console anyway

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so still, instead

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I mean to say is that throw (new InvalidOperationException()); will be less informational than the log. See updated code. But ok, no big deal, I can remove the log too.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about throw new InvalidOperationException($"Only one connection approval handler is supported in {nameof(m_ConnectionApprovalCallback)}. Rejecting further adds."); ? :)

Copy link
Contributor Author

@jeffreyrainy jeffreyrainy May 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, good, we should be good to go now. Please let me know if I missed any bits or parts.

jeffreyrainy and others added 4 commits May 16, 2022 19:21
…ApprovalCallback. Refactored the entire connection approval [code review]
…ApprovalCallback. Refactored the entire connection approval [code review 2]
@0xFA11 0xFA11 changed the title fix: preventing issues with game code registering multiple ConnectionApprovalCallback [MTT-3496] fix: preventing issues with game code registering multiple ConnectionApprovalCallbacks [MTT-3496] May 17, 2022
@0xFA11 0xFA11 enabled auto-merge (squash) May 17, 2022 12:28
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.

2 participants