Teleport notification
- Create end point to permit the teleport notification. The map url will be /teleport/token_user - Create message teleport - Create receive feature in phaser to teleport TODO Teleport player on black room.
This commit is contained in:
parent
3c2f134e4e
commit
65406f844e
8 changed files with 96 additions and 19 deletions
38
back/src/Controller/ReportController.ts
Normal file
38
back/src/Controller/ReportController.ts
Normal file
|
@ -0,0 +1,38 @@
|
|||
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.writeStatus("200 OK").end();
|
||||
} catch (e) {
|
||||
console.log("An error happened", e)
|
||||
res.writeStatus(e.status || "500 Internal Server Error").end('An error happened');
|
||||
}
|
||||
})();
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue