Remove teleport feature

This commit is contained in:
Gregoire Parant 2020-10-15 12:12:11 +02:00
parent 8df56204e3
commit 38d2cc9a8c
5 changed files with 3 additions and 67 deletions

View File

@ -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);
}

View File

@ -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';
}*/
}
}

View File

@ -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);
}
}

View File

@ -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');
}
})();
});
}
}

View File

@ -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);