workadventure/back
2020-04-04 22:43:07 +02:00
..
src Add readme of features and communication in back 2020-04-04 22:43:07 +02:00
.eslintrc.json Create backend 2020-04-04 04:08:12 +02:00
.gitignore Add io socket message to share user position. 2020-04-04 12:42:02 +02:00
package.json Add authenticate 2020-04-04 17:22:02 +02:00
README.md Add readme of features and communication in back 2020-04-04 22:43:07 +02:00
server.ts Create backend 2020-04-04 04:08:12 +02:00
tsconfig.json Refactor and fix error hydration message socket io 2020-04-04 16:25:03 +02:00
yarn.lock Add authenticate 2020-04-04 17:22:02 +02:00

Back Features

Login

To start your game, you must authenticate on the server back. When you are authenticated, the back server return token and rooms started.

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
            }
        },
        ...
    ]

<<< back