Remove middleware to secure access API.
This commit is contained in:
parent
029a7a9a64
commit
69777ad1cb
5 changed files with 38 additions and 60 deletions
|
@ -2,7 +2,7 @@ import {GameManager} from "./Phaser/Game/GameManager";
|
|||
|
||||
const SocketIo = require('socket.io-client');
|
||||
import Axios from "axios";
|
||||
import {API_URL, ROOM} from "./Enum/EnvironmentVariable";
|
||||
import {API_URL} from "./Enum/EnvironmentVariable";
|
||||
|
||||
enum EventMessage{
|
||||
WEBRTC_SIGNAL = "webrtc-signal",
|
||||
|
@ -211,14 +211,16 @@ export class Connexion implements ConnexionInterface {
|
|||
throw err;
|
||||
});
|
||||
}
|
||||
|
||||
loadMaps() : Promise<any>{
|
||||
return Axios.get(`${API_URL}/maps`).then((res) => {
|
||||
return res.data;
|
||||
}).catch((err) => {
|
||||
console.error(err);
|
||||
throw err;
|
||||
});
|
||||
|
||||
//TODO add middleware with access token to secure api
|
||||
loadMaps() : Promise<any> {
|
||||
return Axios.get(`${API_URL}/maps`)
|
||||
.then((res) => {
|
||||
return res.data;
|
||||
}).catch((err) => {
|
||||
console.error(err);
|
||||
throw err;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -93,17 +93,19 @@ export class LogincScene extends Phaser.Scene implements GameSceneInterface {
|
|||
}
|
||||
|
||||
private async login(name: string) {
|
||||
Promise.all([
|
||||
gameManager.connect(name, this.selectedPlayer.texture.key),
|
||||
gameManager.loadMaps()
|
||||
]).then((data) => {
|
||||
if (!data) {
|
||||
return;
|
||||
}
|
||||
let scene: any = data[1];
|
||||
let game = new GameScene(scene.mapStart.key, `${API_URL}${scene.mapStart.url}`);
|
||||
this.scene.add(scene.mapStart.key, game, false);
|
||||
this.scene.start(scene.mapStart.key);
|
||||
return gameManager.connect(name, this.selectedPlayer.texture.key).then(() => {
|
||||
return gameManager.loadMaps().then((scene : any) => {
|
||||
if (!scene) {
|
||||
return;
|
||||
}
|
||||
let game = new GameScene(scene.mapStart.key, `${API_URL}${scene.mapStart.url}`);
|
||||
this.scene.add(scene.mapStart.key, game, false);
|
||||
this.scene.start(scene.mapStart.key);
|
||||
return scene;
|
||||
}).catch((err) => {
|
||||
console.error(err);
|
||||
throw err;
|
||||
});
|
||||
}).catch((err) => {
|
||||
console.error(err);
|
||||
throw err;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue