The listeners from MediaManager and SimplePeer were never removed, leading to a huge amount of listeners all over the applications when switching regularly of scene.
Most of the refactoring issues we are seeing are probably due to the fact that we are trying to manipulate a ScenePlugin out of a Scene (the GameManager is not a Scene and holds a reference to a ScenePlugin coming from a Scene that might get invalidated by Phaser 3).
Furthermore, if we want in the future to be able to scale, scenes could be hosted on different servers. Therefore, it makes no sense to have one connexion for the whole application.
Instead, we should have one connexion for each scene.
I put a connecting spinner around the user name when the user is connecting.
Also, if an error occurs, we will see a blinking red circle around the player name.
Most of the time, sending a disconnect event to one of the players is enough (the player will close the connection
which will be shut for the other player).
However! In the rare case where the WebRTC connection is not yet established, if we close the connection on one of the player,
the other player will try connecting until a timeout happens (during this time, the circle with the name is displayed for nothing).
So now, we send disconnection event to every body (not only the people in the group, but also to the person leaving the group)
Socket.io can stringify JSON messages itself, so there is no need to pass a string to "emit". You can pass a serializable object!
This commit removes all the useless toJson() methods, JSON.serialize and JSON.parse!
Woot!