guilhermebkel / uno-game

:flower_playing_cards: An UNO Game made in Javascript
https://uno.guilherr.me
MIT License
207 stars 59 forks source link

[bug] Socket disconnection on mobile #4

Closed guilhermebkel closed 3 years ago

guilhermebkel commented 3 years ago

When players get into the Table/Room Page on mobile devices and minimizes the Browser, for some reason it causes a disconnection instantly on some devices.

So, being minded about that, we have two possible problems:

ArcaneDiver commented 3 years ago

Hey, i would be glad to help you in this issue. Now about the feedback an idea would be to use this component: Snackbar. About the auto reconnection i think that by adding autoConnect: true would be a solution but i have to investigate more...

Then if you want to assign me this issue πŸ€—

guilhermebkel commented 3 years ago

Hello @ArcaneDiver!

I think the Snackbar is a good idea for giving feedback about the disconnection.

And about the autoConnect: true: I feel like I've tried something like that before but for some reason it did not work πŸ€”

I'll assign you this issue, thanks! 😁

ArcaneDiver commented 3 years ago

Hey i implemented the feedback on disconnection, but i'm having some problem with the reproducing the disconnection on mobile devices. Because i tried on my mobile phone and it perfectly works.

guilhermebkel commented 3 years ago

@ArcaneDiver Got it! Being honest I did not find a pattern on this bug but I know that is the same thing as losing access to the internet after being connected to the socket on some room. So, to recreate it, you could do the following:

  1. Access locally some room using your smartphone.
  2. Disconnect your smartphone from Wi-fi or another network.

That way I think you'll be able to test it πŸ™‚

Since I have two friends who came across this bug, after deploying this to production I can ask them for some testing. Besides, in case you want a log of this disconnection on production I can add some console.logs on the production apps to give a look closer ✌🏻

ArcaneDiver commented 3 years ago

HeyπŸ‘‹, i have finally resolved this issue, now i'll refractor a bit my code, remove tons of console.log, ecc. and I tomorrow i'll make the PR. Just a bit summary of how i resolved the issue.

There was 2 main problems.

guilhermebkel commented 3 years ago

Hello @ArcaneDiver!

At first, thanks for caring about the code you write by doing a refactor on it 😁

Now, about the problems:

  1. This really makes sense, since the SetPlayerData is a core event to keep the player on the application.
  2. It does make sense as well, because when I set this value once, I thought a high value could be better but it is really bad when the player is disconnected from the game.

Thanks for helping to improve this game 😊