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.
In the case the reconnect event was triggered on "wake-up", the disconnect event was not sent. But because of a bug in the way we handle the setTimeout, the reconnection to the GameScene never happened after we forced the disconnect scene.
This fixes the issue.
Callbacks for socket.io events were registered each time a disconnect was called, leading to message being dispatched plenty of times if there was several disconnections.
In case we suspend a laptop and resume it, the RECONNECT event is called by socket.io without any error being thrown (so without us being redirected to the Reconnect Scene).
This fix makes sure we go to the reconnect scene before going back to the main scene.
Remvoing messages that were no more used in the new messaging system (the code used to handle the message that sent the position of all users on the front side)
The URL signature becomes:
https://workadventu.re/_/[instance]/[path_to_map.json]
This allows us to create many instances of the same map (and therefore to create several different worlds for different people)
An exit on a map can target another "instance" by passing the "exitInstance" property.
Now, when a user moves, only his/her position is sent back to the other users. The position of all users is not sent each time.
The messages sent to the browser are now:
- the list of all users as a return to the join_room event (you can send responses to events in socket.io)
- a "join_room" event sent when a new user joins the room
- a "user_moved" event when a user moved
- a "user_left" event when a user left the room
The GameScene tracks all these events and reacts accordingly.
Also, I made a number of refactoring in the classes and removed the GameSceneInterface that was useless (it was implemented by the LogincScene for no reason at all)
Previously, userid was generated by the "/login" route and passed along.
This commit completely removes the uuid "userid" (and disables the LoginController too and any Jwt check).
"userid" is replaced by the "socket id" of the connection.
So a user is now identified using a socket id, which is unique for a given connection.