From 38d2cc9a8cdfeda04bc06eea85e39badf95f5ca8 Mon Sep 17 00:00:00 2001 From: Gregoire Parant Date: Thu, 15 Oct 2020 12:12:11 +0200 Subject: [PATCH] Remove teleport feature --- back/src/App.ts | 3 -- back/src/Controller/BaseController.ts | 7 ---- back/src/Controller/IoSocketController.ts | 17 +--------- back/src/Controller/ReportController.ts | 41 ----------------------- front/src/WebRtc/SimplePeer.ts | 2 ++ 5 files changed, 3 insertions(+), 67 deletions(-) delete mode 100644 back/src/Controller/ReportController.ts diff --git a/back/src/App.ts b/back/src/App.ts index 2cd668d2..6430251a 100644 --- a/back/src/App.ts +++ b/back/src/App.ts @@ -6,7 +6,6 @@ import {PrometheusController} from "./Controller/PrometheusController"; import {FileController} from "./Controller/FileController"; import {DebugController} from "./Controller/DebugController"; import {App as uwsApp} from "./Server/sifrr.server"; -import {ReportController} from "./Controller/ReportController"; class App { public app: uwsApp; @@ -16,7 +15,6 @@ class App { public mapController: MapController; public prometheusController: PrometheusController; private debugController: DebugController; - private reportController: ReportController; constructor() { this.app = new uwsApp(); @@ -26,7 +24,6 @@ class App { this.authenticateController = new AuthenticateController(this.app); this.fileController = new FileController(this.app); this.mapController = new MapController(this.app); - this.reportController = new ReportController(this.app, this.ioSocketController); this.prometheusController = new PrometheusController(this.app, this.ioSocketController); this.debugController = new DebugController(this.app, this.ioSocketController); } diff --git a/back/src/Controller/BaseController.ts b/back/src/Controller/BaseController.ts index 2757519d..0b744082 100644 --- a/back/src/Controller/BaseController.ts +++ b/back/src/Controller/BaseController.ts @@ -8,11 +8,4 @@ export class BaseController { res.writeHeader('access-control-allow-methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE'); res.writeHeader('access-control-allow-origin', '*'); } - - protected checkAdminToken(req: HttpRequest): void { - //TODO - /*if(req.getHeader('Authorization') !== ADMIN_API_TOKEN){ - throw 'Error token api'; - }*/ - } } diff --git a/back/src/Controller/IoSocketController.ts b/back/src/Controller/IoSocketController.ts index 4dfe3576..244262d6 100644 --- a/back/src/Controller/IoSocketController.ts +++ b/back/src/Controller/IoSocketController.ts @@ -31,8 +31,7 @@ import { WebRtcStartMessage, WebRtcDisconnectMessage, PlayGlobalMessage, - ReportPlayerMessage, - TeleportMessageMessage + ReportPlayerMessage } from "../Messages/generated/messages_pb"; import {UserMovesMessage} from "../Messages/generated/messages_pb"; import Direction = PositionMessage.Direction; @@ -889,18 +888,4 @@ export class IoSocketController { } return null; } - - public teleport(userUuid: string) { - const userSocket = this.searchClientByUuid(userUuid); - if (!userSocket) { - throw 'User not found'; - } - const teleportMessageMessage = new TeleportMessageMessage(); - teleportMessageMessage.setMap(`wait/${userSocket.userUuid}`); - - const serverToClientMessage = new ServerToClientMessage(); - serverToClientMessage.setTeleportmessagemessage(teleportMessageMessage); - - userSocket.send(serverToClientMessage.serializeBinary().buffer, true); - } } diff --git a/back/src/Controller/ReportController.ts b/back/src/Controller/ReportController.ts deleted file mode 100644 index 5b5e342d..00000000 --- a/back/src/Controller/ReportController.ts +++ /dev/null @@ -1,41 +0,0 @@ -import {BaseController} from "./BaseController"; -import {HttpRequest, HttpResponse, TemplatedApp} from "uWebSockets.js"; -import {IoSocketController} from "./IoSocketController"; - -export class ReportController extends BaseController { - - constructor(private App: TemplatedApp, private ioSocketController: IoSocketController) { - super(); - this.teleport(); - } - - teleport(){ - this.App.options("/teleport", (res: HttpResponse, req: HttpRequest) => { - this.checkAdminToken(req); - this.addCorsHeaders(res); - res.end(); - }); - - this.App.post("/teleport", (res: HttpResponse, req: HttpRequest) => { - (async () => { - try { - this.checkAdminToken(req); - this.addCorsHeaders(res); - - res.onAborted(() => { - console.warn('Login request was aborted'); - }) - const param = await res.json(); - this.ioSocketController.teleport(param.userUuid); - res.writeHeader('Content-Type', 'application/json'); - res.writeStatus("200 OK").end(JSON.stringify({ - mapUrl: `wait/${param.userUuid}` - })); - } catch (e) { - console.log("An error happened", e) - res.writeStatus(e.status || "500 Internal Server Error").end('An error happened'); - } - })(); - }); - } -} \ No newline at end of file diff --git a/front/src/WebRtc/SimplePeer.ts b/front/src/WebRtc/SimplePeer.ts index 20d10f04..e9f507a0 100644 --- a/front/src/WebRtc/SimplePeer.ts +++ b/front/src/WebRtc/SimplePeer.ts @@ -146,6 +146,8 @@ export class SimplePeer { } mediaManager.removeActiveVideo("" + user.userId); + + //TODO ad condition isPublic or annonyme mediaManager.addActiveVideo("" + user.userId, (comment: string) => { this.reportUser(user.userId, comment); }, name);