Orange-Wallet / wallet-connect-dart

Wallet Connect client in Dart.
https://pub.dev/packages/wallet_connect
BSD 3-Clause "New" or "Revised" License
115 stars 78 forks source link

Issue about the disconnect without reason #53

Open mmMrz opened 1 year ago

mmMrz commented 1 year ago

Sometimes the program will be exited without reason the close code is 1005 For the definition of code, refer to the definition document of Web Socket https://www.rfc-editor.org/rfc/rfc6455#section-7.4

(Actually it's always 1005 when the dapp call loginout, the sdk will not notify program,and direct call disconnect then throw a code of 1005,for example, on opensea.io),see the following code. close listen It is noteworthy that webSocket. webSocket. closeCode webSocket. webSocket. closeReason There are values in.But obviously these are internal properties I can't access. In addition, I added the Reason and Close parameters on my own initiative.

So in the onDisconnect event, I can't determine whether it is an unexpected end or the user's active end (If it is an accidental termination, I can reconnect and continue to communicate with DAPP, but if it is the user's active termination, there is no connection significance.)

The difference between the two is that when DAPP is disconnected, according to the official document of WalletConnect, a SessionUpdate method must be sent. So I added this onSessionUpdate event and called it so that the program can determine whether to reconnect or disconnect add function call add function