Refactored and optimized messages
authorDavid Négrier <d.negrier@thecodingmachine.com>
Tue, 19 May 2020 17:11:12 +0000 (19:11 +0200)
committerDavid Négrier <d.negrier@thecodingmachine.com>
Tue, 19 May 2020 17:11:12 +0000 (19:11 +0200)
commit125a4d11af8c964095da9729c4c860d15e185d05
tree467b3f91b85a565458602f8871d6c8792374765f
parent1e6f9bb8d9f2b2a7cd045833d674b145ca679040
Refactored and optimized messages

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)
12 files changed:
back/src/Controller/IoSocketController.ts
back/src/Model/Websocket/MessageUserJoined.ts [new file with mode: 0644]
back/src/Model/Websocket/MessageUserMoved.ts [new file with mode: 0644]
back/src/Model/Websocket/PointInterface.ts
back/src/Model/World.ts
front/src/Connexion.ts
front/src/Phaser/Game/AddPlayerInterface.ts [new file with mode: 0644]
front/src/Phaser/Game/GameManager.ts
front/src/Phaser/Game/GameScene.ts
front/src/Phaser/Login/LogincScene.ts
front/src/Phaser/Player/Player.ts
front/src/Phaser/UserInput/UserInputManager.ts