Compare commits
1 commit
develop
...
roomLimitC
Author | SHA1 | Date | |
---|---|---|---|
41c8372ee8 |
|
@ -165,9 +165,6 @@ export class IoSocketController {
|
||||||
let memberTags: string[] = [];
|
let memberTags: string[] = [];
|
||||||
let memberTextures: CharacterTexture[] = [];
|
let memberTextures: CharacterTexture[] = [];
|
||||||
const room = await socketManager.getOrCreateRoom(roomId);
|
const room = await socketManager.getOrCreateRoom(roomId);
|
||||||
if(room.isFull){
|
|
||||||
throw new Error('Room is full');
|
|
||||||
}
|
|
||||||
if (ADMIN_API_URL) {
|
if (ADMIN_API_URL) {
|
||||||
try {
|
try {
|
||||||
const userData = await adminApi.fetchMemberDataByUuid(userUuid);
|
const userData = await adminApi.fetchMemberDataByUuid(userUuid);
|
||||||
|
@ -240,9 +237,26 @@ export class IoSocketController {
|
||||||
open: (ws) => {
|
open: (ws) => {
|
||||||
// Let's join the room
|
// Let's join the room
|
||||||
const client = this.initClient(ws); //todo: into the upgrade instead?
|
const client = this.initClient(ws); //todo: into the upgrade instead?
|
||||||
socketManager.handleJoinRoom(client);
|
|
||||||
|
|
||||||
//get data information and show messages
|
//get data information and show messages
|
||||||
|
const room = socketManager.getRoomById(client.roomId);
|
||||||
|
if(room && room.isFull){
|
||||||
|
socketManager.emitSendUserMessage({
|
||||||
|
userUuid: client.userUuid,
|
||||||
|
message: `<p style="text-align: center; font-size: 40px;">
|
||||||
|
Oops, WorkAdventure is a victim of its own success.
|
||||||
|
</p>
|
||||||
|
<p style="text-align: center">
|
||||||
|
You can retry to connect on the platform in a moment.
|
||||||
|
</p>`,
|
||||||
|
type: "RoomFull"
|
||||||
|
}, client);
|
||||||
|
console.info(`user ${client.userUuid} not connected, room is full`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
socketManager.handleJoinRoom(client);
|
||||||
|
|
||||||
if (ADMIN_API_URL) {
|
if (ADMIN_API_URL) {
|
||||||
adminApi.fetchMemberDataByUuid(client.userUuid).then((res: FetchMemberDataByUuidResponse) => {
|
adminApi.fetchMemberDataByUuid(client.userUuid).then((res: FetchMemberDataByUuidResponse) => {
|
||||||
if (!res.messages) {
|
if (!res.messages) {
|
||||||
|
@ -263,6 +277,13 @@ export class IoSocketController {
|
||||||
},
|
},
|
||||||
message: (ws, arrayBuffer, isBinary): void => {
|
message: (ws, arrayBuffer, isBinary): void => {
|
||||||
const client = ws as ExSocketInterface;
|
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));
|
const message = ClientToServerMessage.deserializeBinary(new Uint8Array(arrayBuffer));
|
||||||
|
|
||||||
if (message.hasViewportmessage()) {
|
if (message.hasViewportmessage()) {
|
||||||
|
|
|
@ -365,6 +365,10 @@ export class SocketManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getRoomById(roomId: string) : GameRoom|undefined {
|
||||||
|
return this.Worlds.get(roomId)
|
||||||
|
}
|
||||||
|
|
||||||
async getOrCreateRoom(roomId: string): Promise<GameRoom> {
|
async getOrCreateRoom(roomId: string): Promise<GameRoom> {
|
||||||
//check and create new world for a room
|
//check and create new world for a room
|
||||||
let world = this.Worlds.get(roomId)
|
let world = this.Worlds.get(roomId)
|
||||||
|
@ -658,10 +662,15 @@ export class SocketManager {
|
||||||
client.send(serverToClientMessage.serializeBinary().buffer, true);
|
client.send(serverToClientMessage.serializeBinary().buffer, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public emitSendUserMessage(messageToSend: {userUuid: string, message: string, type: string}): ExSocketInterface {
|
public emitSendUserMessage(messageToSend: {userUuid: string, message: string, type: string},
|
||||||
const socket = this.searchClientByUuid(messageToSend.userUuid);
|
client?: ExSocketInterface): ExSocketInterface {
|
||||||
|
let socket = client;
|
||||||
if(!socket){
|
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();
|
const sendUserMessage = new SendUserMessage();
|
||||||
|
|
|
@ -4,9 +4,9 @@ import {HtmlUtils} from "../WebRtc/HtmlUtils";
|
||||||
let modalTimeOut : NodeJS.Timeout;
|
let modalTimeOut : NodeJS.Timeout;
|
||||||
|
|
||||||
export class TypeMessageExt implements TypeMessageInterface{
|
export class TypeMessageExt implements TypeMessageInterface{
|
||||||
private nbSecond = 0;
|
protected nbSecond = 0;
|
||||||
private maxNbSecond = 10;
|
protected maxNbSecond = 10;
|
||||||
private titleMessage = 'IMPORTANT !';
|
protected titleMessage = 'IMPORTANT !';
|
||||||
|
|
||||||
showMessage(message: string, canDeleteMessage: boolean = true): void {
|
showMessage(message: string, canDeleteMessage: boolean = true): void {
|
||||||
//delete previous modal
|
//delete previous modal
|
||||||
|
@ -37,7 +37,7 @@ export class TypeMessageExt implements TypeMessageInterface{
|
||||||
|
|
||||||
const p : HTMLParagraphElement = document.createElement('p');
|
const p : HTMLParagraphElement = document.createElement('p');
|
||||||
p.id = 'body-report-user'
|
p.id = 'body-report-user'
|
||||||
p.innerText = message;
|
p.innerHTML = message;
|
||||||
div.appendChild(p);
|
div.appendChild(p);
|
||||||
|
|
||||||
const mainSectionDiv = HtmlUtils.getElementByIdOrFail<HTMLDivElement>('main-container');
|
const mainSectionDiv = HtmlUtils.getElementByIdOrFail<HTMLDivElement>('main-container');
|
||||||
|
@ -84,4 +84,11 @@ export class Banned extends TypeMessageExt {
|
||||||
showMessage(message: string){
|
showMessage(message: string){
|
||||||
super.showMessage(message, false);
|
super.showMessage(message, false);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class RoomFull extends TypeMessageExt {
|
||||||
|
showMessage(message: string){
|
||||||
|
this.maxNbSecond = 30;
|
||||||
|
super.showMessage(message);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -8,7 +8,6 @@ import Container = Phaser.GameObjects.Container;
|
||||||
import {gameManager} from "../Game/GameManager";
|
import {gameManager} from "../Game/GameManager";
|
||||||
import {ResizableScene} from "./ResizableScene";
|
import {ResizableScene} from "./ResizableScene";
|
||||||
import {localUserStore} from "../../Connexion/LocalUserStore";
|
import {localUserStore} from "../../Connexion/LocalUserStore";
|
||||||
import {PlayerResourceDescriptionInterface} from "../Entity/Character";
|
|
||||||
|
|
||||||
export const CustomizeSceneName = "CustomizeScene";
|
export const CustomizeSceneName = "CustomizeScene";
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue