Fixing benchmark

This commit is contained in:
David Négrier 2020-09-29 17:24:16 +02:00
parent 9f3577286d
commit 53c6c2bc30
4 changed files with 15 additions and 17 deletions

View File

@ -244,14 +244,10 @@ export class IoSocketController {
//leave room //leave room
this.leaveRoom(Client); this.leaveRoom(Client);
//leave webrtc room
//socket.leave(Client.webRtcRoomId);
//delete all socket information //delete all socket information
delete Client.webRtcRoomId; /*delete Client.roomId;
delete Client.roomId;
delete Client.token; delete Client.token;
delete Client.position; delete Client.position;*/
} catch (e) { } catch (e) {
console.error('An error occurred on "disconnect"'); console.error('An error occurred on "disconnect"');
console.error(e); console.error(e);
@ -308,7 +304,7 @@ export class IoSocketController {
} }
//leave previous room //leave previous room
this.leaveRoom(Client); //this.leaveRoom(Client); // Useless now, there is only one room per connection
//join new previous room //join new previous room
const world = this.joinRoom(Client, roomId, ProtobufUtils.toPointInterface(message.getPosition() as PositionMessage)); const world = this.joinRoom(Client, roomId, ProtobufUtils.toPointInterface(message.getPosition() as PositionMessage));
@ -567,7 +563,7 @@ export class IoSocketController {
//Client.leave(Client.roomId); //Client.leave(Client.roomId);
} finally { } finally {
this.nbClientsPerRoomGauge.dec({ room: Client.roomId }); this.nbClientsPerRoomGauge.dec({ room: Client.roomId });
delete Client.roomId; //delete Client.roomId;
} }
} }
} }
@ -694,8 +690,6 @@ export class IoSocketController {
return; return;
}*/ }*/
// TODO: joinWebRtcRoom will be trigerred twice when joining the first time! Maybe we should fix the GROUP constructor to trigger only one event
console.log('joinWebRtcRoom FOR '+user.socket.name+" "+user.socket.userId);
for (const otherUser of group.getUsers()) { for (const otherUser of group.getUsers()) {
if (user === otherUser) { if (user === otherUser) {
continue; continue;
@ -712,7 +706,7 @@ console.log('joinWebRtcRoom FOR '+user.socket.name+" "+user.socket.userId);
if (!user.socket.disconnecting) { if (!user.socket.disconnecting) {
user.socket.send(serverToClientMessage1.serializeBinary().buffer, true); user.socket.send(serverToClientMessage1.serializeBinary().buffer, true);
console.log('Sending webrtcstart initiator to '+user.socket.userId) //console.log('Sending webrtcstart initiator to '+user.socket.userId)
} }
const webrtcStartMessage2 = new WebRtcStartMessage(); const webrtcStartMessage2 = new WebRtcStartMessage();
@ -725,7 +719,7 @@ console.log('joinWebRtcRoom FOR '+user.socket.name+" "+user.socket.userId);
if (!otherUser.socket.disconnecting) { if (!otherUser.socket.disconnecting) {
otherUser.socket.send(serverToClientMessage2.serializeBinary().buffer, true); otherUser.socket.send(serverToClientMessage2.serializeBinary().buffer, true);
console.log('Sending webrtcstart to '+otherUser.socket.userId) //console.log('Sending webrtcstart to '+otherUser.socket.userId)
} }
} }

View File

@ -7,7 +7,6 @@ import {WebSocket} from "uWebSockets.js"
export interface ExSocketInterface extends WebSocket, Identificable { export interface ExSocketInterface extends WebSocket, Identificable {
token: string; token: string;
roomId: string; roomId: string;
webRtcRoomId: string|undefined;
userId: number; // A temporary (autoincremented) identifier for this user userId: number; // A temporary (autoincremented) identifier for this user
userUuid: string; // A unique identifier for this user userUuid: string; // A unique identifier for this user
name: string; name: string;

View File

@ -1,4 +1,5 @@
import {RoomConnection} from "../front/src/Connexion/Connection"; import {RoomConnection} from "../front/src/Connexion/RoomConnection";
import {connectionManager} from "../front/src/Connexion/ConnectionManager";
import * as WebSocket from "ws" import * as WebSocket from "ws"
function sleep(ms) { function sleep(ms) {
@ -10,7 +11,8 @@ RoomConnection.setWebsocketFactory((url: string) => {
}); });
async function startOneUser(): Promise<void> { async function startOneUser(): Promise<void> {
const connection = await RoomConnection.createConnection('foo', ['male3']); const connection = await connectionManager.connectToRoomSocket();
connection.emitPlayerDetailsMessage('foo', ['male3']);
await connection.joinARoom('global__maps.workadventure.localhost/Floor0/floor0', 783, 170, 'down', false, { await connection.joinARoom('global__maps.workadventure.localhost/Floor0/floor0', 783, 170, 'down', false, {
top: 0, top: 0,
@ -43,6 +45,9 @@ async function startOneUser(): Promise<void> {
} }
(async () => { (async () => {
//await connectionManager.init();
for (let userNo = 0; userNo < 40; userNo++) { for (let userNo = 0; userNo < 40; userNo++) {
startOneUser(); startOneUser();
// Wait 0.5s between adding users // Wait 0.5s between adding users

View File

@ -61,7 +61,7 @@ export class RoomConnection implements RoomConnection {
this.socket.binaryType = 'arraybuffer'; this.socket.binaryType = 'arraybuffer';
this.socket.onopen = (ev) => { this.socket.onopen = (ev) => {
console.log('WS connected'); //console.log('WS connected');
}; };
this.socket.onmessage = (messageEvent) => { this.socket.onmessage = (messageEvent) => {
@ -143,7 +143,7 @@ export class RoomConnection implements RoomConnection {
public emitPlayerDetailsMessage(userName: string, characterLayersSelected: string[]) { public emitPlayerDetailsMessage(userName: string, characterLayersSelected: string[]) {
const message = new SetPlayerDetailsMessage(); const message = new SetPlayerDetailsMessage();
message.setName(name); message.setName(userName);
message.setCharacterlayersList(characterLayersSelected); message.setCharacterlayersList(characterLayersSelected);
const clientToServerMessage = new ClientToServerMessage(); const clientToServerMessage = new ClientToServerMessage();