Remove teleport feature
This commit is contained in:
parent
8df56204e3
commit
38d2cc9a8c
@ -6,7 +6,6 @@ import {PrometheusController} from "./Controller/PrometheusController";
|
|||||||
import {FileController} from "./Controller/FileController";
|
import {FileController} from "./Controller/FileController";
|
||||||
import {DebugController} from "./Controller/DebugController";
|
import {DebugController} from "./Controller/DebugController";
|
||||||
import {App as uwsApp} from "./Server/sifrr.server";
|
import {App as uwsApp} from "./Server/sifrr.server";
|
||||||
import {ReportController} from "./Controller/ReportController";
|
|
||||||
|
|
||||||
class App {
|
class App {
|
||||||
public app: uwsApp;
|
public app: uwsApp;
|
||||||
@ -16,7 +15,6 @@ class App {
|
|||||||
public mapController: MapController;
|
public mapController: MapController;
|
||||||
public prometheusController: PrometheusController;
|
public prometheusController: PrometheusController;
|
||||||
private debugController: DebugController;
|
private debugController: DebugController;
|
||||||
private reportController: ReportController;
|
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.app = new uwsApp();
|
this.app = new uwsApp();
|
||||||
@ -26,7 +24,6 @@ class App {
|
|||||||
this.authenticateController = new AuthenticateController(this.app);
|
this.authenticateController = new AuthenticateController(this.app);
|
||||||
this.fileController = new FileController(this.app);
|
this.fileController = new FileController(this.app);
|
||||||
this.mapController = new MapController(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.prometheusController = new PrometheusController(this.app, this.ioSocketController);
|
||||||
this.debugController = new DebugController(this.app, this.ioSocketController);
|
this.debugController = new DebugController(this.app, this.ioSocketController);
|
||||||
}
|
}
|
||||||
|
@ -8,11 +8,4 @@ export class BaseController {
|
|||||||
res.writeHeader('access-control-allow-methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');
|
res.writeHeader('access-control-allow-methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');
|
||||||
res.writeHeader('access-control-allow-origin', '*');
|
res.writeHeader('access-control-allow-origin', '*');
|
||||||
}
|
}
|
||||||
|
|
||||||
protected checkAdminToken(req: HttpRequest): void {
|
|
||||||
//TODO
|
|
||||||
/*if(req.getHeader('Authorization') !== ADMIN_API_TOKEN){
|
|
||||||
throw 'Error token api';
|
|
||||||
}*/
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -31,8 +31,7 @@ import {
|
|||||||
WebRtcStartMessage,
|
WebRtcStartMessage,
|
||||||
WebRtcDisconnectMessage,
|
WebRtcDisconnectMessage,
|
||||||
PlayGlobalMessage,
|
PlayGlobalMessage,
|
||||||
ReportPlayerMessage,
|
ReportPlayerMessage
|
||||||
TeleportMessageMessage
|
|
||||||
} from "../Messages/generated/messages_pb";
|
} from "../Messages/generated/messages_pb";
|
||||||
import {UserMovesMessage} from "../Messages/generated/messages_pb";
|
import {UserMovesMessage} from "../Messages/generated/messages_pb";
|
||||||
import Direction = PositionMessage.Direction;
|
import Direction = PositionMessage.Direction;
|
||||||
@ -889,18 +888,4 @@ export class IoSocketController {
|
|||||||
}
|
}
|
||||||
return null;
|
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -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');
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
@ -146,6 +146,8 @@ export class SimplePeer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mediaManager.removeActiveVideo("" + user.userId);
|
mediaManager.removeActiveVideo("" + user.userId);
|
||||||
|
|
||||||
|
//TODO ad condition isPublic or annonyme
|
||||||
mediaManager.addActiveVideo("" + user.userId, (comment: string) => {
|
mediaManager.addActiveVideo("" + user.userId, (comment: string) => {
|
||||||
this.reportUser(user.userId, comment);
|
this.reportUser(user.userId, comment);
|
||||||
}, name);
|
}, name);
|
||||||
|
Loading…
Reference in New Issue
Block a user