Share players position using Socket.IO

- 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.
This commit is contained in:
gparant 2020-04-04 19:25:08 +02:00
parent f04d1342b5
commit fbcb48f9ad
4 changed files with 71 additions and 8 deletions

View file

@ -1,7 +1,7 @@
import {Application, Request, Response} from "express";
import Jwt, {JsonWebTokenError} from "jsonwebtoken";
import {BAD_REQUEST, OK} from "http-status-codes";
import {SECRET_KEY} from "../Enum/EnvironmentVariable";
import {SECRET_KEY, ROOM} from "../Enum/EnvironmentVariable";
export class AuthenticateController{
App : Application;
@ -21,7 +21,7 @@ export class AuthenticateController{
});
}
//TODO check user email for The Coding Machine game
let token = Jwt.sign({email: param.email}, SECRET_KEY, {expiresIn: '24h'});
let token = Jwt.sign({email: param.email, roomId: ROOM}, SECRET_KEY, {expiresIn: '24h'});
return res.status(OK).send({token: token});
});
}