Get tags from the admin
And uses tag "admin" to choose whether to display the console or not
This commit is contained in:
@@ -43,6 +43,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;
|
||||
@@ -124,6 +125,7 @@ export class RoomConnection implements RoomConnection {
|
||||
}
|
||||
|
||||
this.userId = roomJoinedMessage.getCurrentuserid();
|
||||
this.tags = roomJoinedMessage.getTagList();
|
||||
|
||||
this.dispatch(EventMessage.START_ROOM, {
|
||||
users,
|
||||
@@ -478,4 +480,8 @@ export class RoomConnection implements RoomConnection {
|
||||
|
||||
this.socket.send(clientToServerMessage.serializeBinary().buffer);
|
||||
}
|
||||
|
||||
public hasTag(tag: string): boolean {
|
||||
return this.tags.indexOf(tag) !== -1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -397,9 +397,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();
|
||||
|
||||
@@ -530,6 +527,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) => {
|
||||
|
||||
Reference in New Issue
Block a user