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

Added new willReconnect method to Client and Server delegates #125

Merged
merged 3 commits into from
Jul 12, 2022

Conversation

oscahie
Copy link
Contributor

@oscahie oscahie commented Jul 11, 2022

With this new delegate method it should be possible for API users to track the actual connection status of each session. This is helpful when you'd want your UI to reflect whenever a session has lost its connection and thus wallet connect events won't work until it's been reconnected.

It'd work like this:

  • Assume all sessions are in disconnected state by default
  • on delegate's didConnect method update state to connected
  • on delegate's willReconnect method update state to disconnected

…makes it possible for API users to track the actual connection status of each session.
@DmitryBespalov
Copy link
Collaborator

sorry, this has merge conflicts now

@oscahie
Copy link
Contributor Author

oscahie commented Jul 11, 2022

sorry, this has merge conflicts now

Solved! :)

@@ -10,6 +10,12 @@ public protocol ClientDelegate: AnyObject {
func client(_ client: Client, didConnect session: Session)
func client(_ client: Client, didDisconnect session: Session)
func client(_ client: Client, didUpdate session: Session)
func client(_ client: Client, willReconnect session: Session)
Copy link
Collaborator

Choose a reason for hiding this comment

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

do you want to move it to a separate Client2Delegate?

I don't remember the specifics (why I didn't go for the change to the ClientDelegate + default implementation), but the reason was to not break any source code that would update the library version.

I'll double check this anyway during review.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a possibility too, I didn't have the latest changes when coding this new method. Although from a pure aesthetics point of view I kinda like it better in the original delegate protocol 😀 Up to you, really.

Copy link
Collaborator

@DmitryBespalov DmitryBespalov Jul 11, 2022

Choose a reason for hiding this comment

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

Ok, I have checked out the branch in my main project, and the build fails because my existing class does not conform to protocol ServerDelegate now.

Please move this method to the Client2Delegate protocol, and the same for the ServerDelegate - to the ServerDelegateV2

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, done!

@oscahie oscahie force-pushed the oscar/willReconnect branch from c4eec9f to 08326c9 Compare July 11, 2022 15:54
@DmitryBespalov DmitryBespalov merged commit 31e350d into WalletConnect:master Jul 12, 2022
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