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
this.leaveRoom(Client);
//leave webrtc room
//socket.leave(Client.webRtcRoomId);
//delete all socket information
delete Client.webRtcRoomId;
delete Client.roomId;
/*delete Client.roomId;
delete Client.token;
delete Client.position;
delete Client.position;*/
} catch (e) {
console.error('An error occurred on "disconnect"');
console.error(e);
@ -308,7 +304,7 @@ export class IoSocketController {
}
//leave previous room
this.leaveRoom(Client);
//this.leaveRoom(Client); // Useless now, there is only one room per connection
//join new previous room
const world = this.joinRoom(Client, roomId, ProtobufUtils.toPointInterface(message.getPosition() as PositionMessage));
@ -567,7 +563,7 @@ export class IoSocketController {
//Client.leave(Client.roomId);
} finally {
this.nbClientsPerRoomGauge.dec({ room: Client.roomId });
delete Client.roomId;
//delete Client.roomId;
}
}
}
@ -694,8 +690,6 @@ export class IoSocketController {
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()) {
if (user === otherUser) {
continue;
@ -712,7 +706,7 @@ console.log('joinWebRtcRoom FOR '+user.socket.name+" "+user.socket.userId);
if (!user.socket.disconnecting) {
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();
@ -725,7 +719,7 @@ console.log('joinWebRtcRoom FOR '+user.socket.name+" "+user.socket.userId);
if (!otherUser.socket.disconnecting) {
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 {
token: string;
roomId: string;
webRtcRoomId: string|undefined;
userId: number; // A temporary (autoincremented) identifier for this user
userUuid: string; // A unique identifier for this user
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"
function sleep(ms) {
@ -10,7 +11,8 @@ RoomConnection.setWebsocketFactory((url: string) => {
});
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, {
top: 0,
@ -43,6 +45,9 @@ async function startOneUser(): Promise<void> {
}
(async () => {
//await connectionManager.init();
for (let userNo = 0; userNo < 40; userNo++) {
startOneUser();
// Wait 0.5s between adding users

View file

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