Merge
This commit is contained in:
commit
7dc3d9d836
51 changed files with 3692 additions and 294 deletions
|
@ -2,6 +2,7 @@ import {Application, Request, Response} from "express";
|
|||
import Jwt from "jsonwebtoken";
|
||||
import {BAD_REQUEST, OK} from "http-status-codes";
|
||||
import {SECRET_KEY, ROOM} from "../Enum/EnvironmentVariable"; //TODO fix import by "_Enum/..."
|
||||
import { uuid } from 'uuidv4';
|
||||
|
||||
export class AuthenticateController{
|
||||
App : Application;
|
||||
|
@ -21,8 +22,13 @@ export class AuthenticateController{
|
|||
});
|
||||
}
|
||||
//TODO check user email for The Coding Machine game
|
||||
let token = Jwt.sign({email: param.email, roomId: ROOM}, SECRET_KEY, {expiresIn: '24h'});
|
||||
return res.status(OK).send({token: token, roomId: ROOM});
|
||||
let userId = uuid();
|
||||
let token = Jwt.sign({email: param.email, roomId: ROOM, userId: userId}, SECRET_KEY, {expiresIn: '24h'});
|
||||
return res.status(OK).send({
|
||||
token: token,
|
||||
roomId: ROOM,
|
||||
userId: userId
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
|
@ -104,7 +104,8 @@ export class IoSocketController{
|
|||
roomId: <string>,
|
||||
position: {
|
||||
x : <number>,
|
||||
y : <number>
|
||||
y : <number>,
|
||||
direction: <string>
|
||||
}
|
||||
},
|
||||
...
|
||||
|
@ -125,8 +126,7 @@ export class IoSocketController{
|
|||
}
|
||||
arrayMap.forEach((value : any) => {
|
||||
let roomId = value[0];
|
||||
let data = value[1];
|
||||
this.Io.in(roomId).emit('user-position', JSON.stringify(data));
|
||||
this.Io.in(roomId).emit('user-position', JSON.stringify(arrayMap));
|
||||
});
|
||||
this.seTimeOutInProgress = setTimeout(() => {
|
||||
this.shareUsersPosition();
|
||||
|
|
|
@ -4,19 +4,22 @@ import {PointInterface} from "./PointInterface";
|
|||
export class Point implements PointInterface{
|
||||
x: number;
|
||||
y: number;
|
||||
direction: string;
|
||||
|
||||
constructor(x : number, y : number) {
|
||||
constructor(x : number, y : number, direction : string = "none") {
|
||||
if(x === null || y === null){
|
||||
throw Error("position x and y cannot be null");
|
||||
}
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.direction = direction;
|
||||
}
|
||||
|
||||
toJson(){
|
||||
return {
|
||||
x : this.x,
|
||||
y: this.y
|
||||
y: this.y,
|
||||
direction: this.direction
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +29,7 @@ export class MessageUserPosition extends Message{
|
|||
|
||||
constructor(data: any) {
|
||||
super(data);
|
||||
this.position = new Point(data.position.x, data.position.y);
|
||||
this.position = new Point(data.position.x, data.position.y, data.position.direction);
|
||||
}
|
||||
|
||||
toString() {
|
||||
|
@ -38,4 +41,4 @@ export class MessageUserPosition extends Message{
|
|||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
export interface PointInterface {
|
||||
x: number;
|
||||
y: number;
|
||||
direction: string;
|
||||
toJson() : object;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue