96c5d92c46
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) |
||
---|---|---|
.. | ||
src | ||
tests | ||
.dockerignore | ||
.eslintrc.json | ||
.gitignore | ||
Dockerfile | ||
jasmine.json | ||
package.json | ||
position-test.js | ||
README.md | ||
server.ts | ||
tsconfig.json | ||
yarn.lock |
Back Features
Login
To start your game, you must authenticate on the server back. When you are authenticated, the back server return token and room starting.
POST => /login
Params :
email: email of user.
Join a room
When a user is connected, the user can join a room.
So you must send emit join-room
with information user:
Socket.io => 'join-room'
userId: user id of gamer
roomId: room id when user enter in game
position: {
x: position x on map
y: position y on map
}
All data users are stocked on socket client.
Send position user
When user move on the map, you can share new position on back with event user-position
.
The information sent:
Socket.io => 'user-position'
userId: user id of gamer
roomId: room id when user enter in game
position: {
x: position x on map
y: position y on map
}
All data users are updated on socket client.
Receive positions of all users
The application sends position of all users in each room in every few 10 milliseconds.
The data will pushed on event user-position
:
Socket.io => 'user-position'
[
{
userId: user id of gamer
roomId: room id when user enter in game
position: {
x: position x on map
y: position y on map
}
},
...
]