Fixing benchmark

This commit is contained in:
David Négrier 2020-12-03 17:19:56 +01:00
parent a19edd4dc1
commit e89ed8cca8

View File

@ -2,6 +2,7 @@ import {RoomConnection} from "../front/src/Connexion/RoomConnection";
import {connectionManager} from "../front/src/Connexion/ConnectionManager"; import {connectionManager} from "../front/src/Connexion/ConnectionManager";
import * as WebSocket from "ws" import * as WebSocket from "ws"
let userMovedCount = 0;
function sleep(ms) { function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms)); return new Promise(resolve => setTimeout(resolve, ms));
@ -13,7 +14,7 @@ RoomConnection.setWebsocketFactory((url: string) => {
async function startOneUser(): Promise<void> { async function startOneUser(): Promise<void> {
await connectionManager.anonymousLogin(true); await connectionManager.anonymousLogin(true);
const connection = await connectionManager.connectToRoomSocket(process.env.ROOM_ID ? process.env.ROOM_ID : '_/global/maps.workadventure.localhost/Floor0/floor0.json', 'TEST', ['male3'], const onConnect = await connectionManager.connectToRoomSocket(process.env.ROOM_ID ? process.env.ROOM_ID : '_/global/maps.workadventure.localhost/Floor0/floor0.json', 'TEST', ['male3'],
{ {
x: 783, x: 783,
y: 170 y: 170
@ -24,6 +25,12 @@ async function startOneUser(): Promise<void> {
right: 800 right: 800
}); });
const connection = onConnect.connection;
connection.onUserMoved(() => {
userMovedCount++;
})
console.log(connection.getUserId()); console.log(connection.getUserId());
let angle = Math.random() * Math.PI * 2; let angle = Math.random() * Math.PI * 2;
@ -46,6 +53,7 @@ async function startOneUser(): Promise<void> {
await sleep(10000); await sleep(10000);
connection.closeConnection(); connection.closeConnection();
console.log('User moved count: '+userMovedCount);
} }
(async () => { (async () => {
@ -57,4 +65,5 @@ async function startOneUser(): Promise<void> {
// Wait 0.5s between adding users // Wait 0.5s between adding users
await sleep(125); await sleep(125);
} }
})(); })();