To do this, I used generic-type-guard package which generates both an interface AND a valid type guard from code.
With this, we are 100% sure that the messages we receive are validated at runtime!
The client cannot pass us an object that is invalid! \o/
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.
The "frame" variable actually contains a string pointing to the character selected.
It has nothing to do with a frame which is usually a particular image in an animation.
I'm renaming the variable accross the application to avoid confusion.
- I stocked information user (id, room and position) in socket client.
- I created function to send all information every few 10 milliseconds.
Note : when the front will be available, we must check the performance of back server.
- Position message send will be on format :
message :
userId : user identification
roomId: room identification
position: position of user in map
x: user x position on map
y: user y position on map
- Create Point object and interface to have position x and y of user in map.