Merge branch 'develop' into player-report

# Conflicts:
#	front/src/Connexion/RoomConnection.ts
This commit is contained in:
Gregoire Parant 2020-10-14 15:06:10 +02:00
commit 4799460064
11 changed files with 56 additions and 20 deletions

View file

@ -66,7 +66,7 @@ export class Room {
this.instance = match[1];
return this.instance;
} else {
const match = /_\/([^/]+)\/([^/]+)\/.+/.exec(this.id);
const match = /@\/([^/]+)\/([^/]+)\/.+/.exec(this.id);
if (!match) throw new Error('Could not extract instance from "'+this.id+'"');
this.instance = match[1]+'/'+match[2];
return this.instance;

View file

@ -45,6 +45,7 @@ export class RoomConnection implements RoomConnection {
private listeners: Map<string, Function[]> = new Map<string, Function[]>();
private static websocketFactory: null|((url: string)=>any) = null; // eslint-disable-line @typescript-eslint/no-explicit-any
private closed: boolean = false;
private tags: string[] = [];
public static setWebsocketFactory(websocketFactory: (url: string)=>any): void { // eslint-disable-line @typescript-eslint/no-explicit-any
RoomConnection.websocketFactory = websocketFactory;
@ -126,6 +127,7 @@ export class RoomConnection implements RoomConnection {
}
this.userId = roomJoinedMessage.getCurrentuserid();
this.tags = roomJoinedMessage.getTagList();
this.dispatch(EventMessage.START_ROOM, {
users,
@ -498,4 +500,8 @@ export class RoomConnection implements RoomConnection {
this.socket.send(clientToServerMessage.serializeBinary().buffer);
}
public hasTag(tag: string): boolean {
return this.tags.includes(tag);
}
}

View file

@ -385,9 +385,6 @@ export class GameScene extends ResizableScene implements CenterListener {
//create input to move
this.userInputManager = new UserInputManager(this);
//TODO check right of user
this.ConsoleGlobalMessageManager = new ConsoleGlobalMessageManager(this.connection, this.userInputManager);
//notify game manager can to create currentUser in map
this.createCurrentPlayer();
@ -518,6 +515,10 @@ export class GameScene extends ResizableScene implements CenterListener {
connection.onStartRoom((roomJoinedMessage: RoomJoinedMessageInterface) => {
this.initUsersPosition(roomJoinedMessage.users);
this.connectionAnswerPromiseResolve(roomJoinedMessage);
// Analyze tags to find if we are admin. If yes, show console.
if (this.connection.hasTag('admin')) {
this.ConsoleGlobalMessageManager = new ConsoleGlobalMessageManager(this.connection, this.userInputManager);
}
});
connection.onUserJoins((message: MessageUserJoined) => {