diff --git a/back/src/Controller/IoSocketController.ts b/back/src/Controller/IoSocketController.ts
index f037a99d..4a17a975 100644
--- a/back/src/Controller/IoSocketController.ts
+++ b/back/src/Controller/IoSocketController.ts
@@ -165,9 +165,6 @@ export class IoSocketController {
let memberTags: string[] = [];
let memberTextures: CharacterTexture[] = [];
const room = await socketManager.getOrCreateRoom(roomId);
- if(room.isFull){
- throw new Error('Room is full');
- }
if (ADMIN_API_URL) {
try {
const userData = await adminApi.fetchMemberDataByUuid(userUuid);
@@ -240,9 +237,26 @@ export class IoSocketController {
open: (ws) => {
// Let's join the room
const client = this.initClient(ws); //todo: into the upgrade instead?
- socketManager.handleJoinRoom(client);
//get data information and show messages
+ const room = socketManager.getRoomById(client.roomId);
+ if(room && room.isFull){
+ socketManager.emitSendUserMessage({
+ userUuid: client.userUuid,
+ message: `
+ Oops, WorkAdventure is a victim of its own success.
+
+
+ You can retry to connect on the platform in a moment.
+
`,
+ type: "RoomFull"
+ }, client);
+ console.info(`user ${client.userUuid} not connected, room is full`);
+ return;
+ }
+
+ socketManager.handleJoinRoom(client);
+
if (ADMIN_API_URL) {
adminApi.fetchMemberDataByUuid(client.userUuid).then((res: FetchMemberDataByUuidResponse) => {
if (!res.messages) {
@@ -263,6 +277,13 @@ export class IoSocketController {
},
message: (ws, arrayBuffer, isBinary): void => {
const client = ws as ExSocketInterface;
+
+ //permit to stop treatment message when the room is full
+ const room = socketManager.getRoomById(client.roomId);
+ if(room && room.isFull){
+ return;
+ }
+
const message = ClientToServerMessage.deserializeBinary(new Uint8Array(arrayBuffer));
if (message.hasViewportmessage()) {
diff --git a/back/src/Services/SocketManager.ts b/back/src/Services/SocketManager.ts
index 97f008c4..0ceddfbc 100644
--- a/back/src/Services/SocketManager.ts
+++ b/back/src/Services/SocketManager.ts
@@ -365,6 +365,10 @@ export class SocketManager {
}
}
+ getRoomById(roomId: string) : GameRoom|undefined {
+ return this.Worlds.get(roomId)
+ }
+
async getOrCreateRoom(roomId: string): Promise {
//check and create new world for a room
let world = this.Worlds.get(roomId)
@@ -658,10 +662,15 @@ export class SocketManager {
client.send(serverToClientMessage.serializeBinary().buffer, true);
}
- public emitSendUserMessage(messageToSend: {userUuid: string, message: string, type: string}): ExSocketInterface {
- const socket = this.searchClientByUuid(messageToSend.userUuid);
+ public emitSendUserMessage(messageToSend: {userUuid: string, message: string, type: string},
+ client?: ExSocketInterface): ExSocketInterface {
+ let socket = client;
if(!socket){
- throw 'socket was not found';
+ const socketFind = this.searchClientByUuid(messageToSend.userUuid);
+ if (!socketFind) {
+ throw 'socket was not found';
+ }
+ socket = socketFind;
}
const sendUserMessage = new SendUserMessage();
diff --git a/front/src/Administration/TypeMessage.ts b/front/src/Administration/TypeMessage.ts
index 61891604..da11faf3 100644
--- a/front/src/Administration/TypeMessage.ts
+++ b/front/src/Administration/TypeMessage.ts
@@ -4,9 +4,9 @@ import {HtmlUtils} from "../WebRtc/HtmlUtils";
let modalTimeOut : NodeJS.Timeout;
export class TypeMessageExt implements TypeMessageInterface{
- private nbSecond = 0;
- private maxNbSecond = 10;
- private titleMessage = 'IMPORTANT !';
+ protected nbSecond = 0;
+ protected maxNbSecond = 10;
+ protected titleMessage = 'IMPORTANT !';
showMessage(message: string, canDeleteMessage: boolean = true): void {
//delete previous modal
@@ -37,7 +37,7 @@ export class TypeMessageExt implements TypeMessageInterface{
const p : HTMLParagraphElement = document.createElement('p');
p.id = 'body-report-user'
- p.innerText = message;
+ p.innerHTML = message;
div.appendChild(p);
const mainSectionDiv = HtmlUtils.getElementByIdOrFail('main-container');
@@ -84,4 +84,11 @@ export class Banned extends TypeMessageExt {
showMessage(message: string){
super.showMessage(message, false);
}
+}
+
+export class RoomFull extends TypeMessageExt {
+ showMessage(message: string){
+ this.maxNbSecond = 30;
+ super.showMessage(message);
+ }
}
\ No newline at end of file
diff --git a/front/src/Phaser/Login/CustomizeScene.ts b/front/src/Phaser/Login/CustomizeScene.ts
index 41ec95c9..06894df1 100644
--- a/front/src/Phaser/Login/CustomizeScene.ts
+++ b/front/src/Phaser/Login/CustomizeScene.ts
@@ -8,7 +8,6 @@ import Container = Phaser.GameObjects.Container;
import {gameManager} from "../Game/GameManager";
import {ResizableScene} from "./ResizableScene";
import {localUserStore} from "../../Connexion/LocalUserStore";
-import {PlayerResourceDescriptionInterface} from "../Entity/Character";
export const CustomizeSceneName = "CustomizeScene";