Changing load test to run in circles

This commit is contained in:
David Négrier 2020-09-16 09:31:44 +02:00
parent d24ec0bd75
commit 7e7b42ce19
3 changed files with 24 additions and 6 deletions

View File

@ -223,6 +223,14 @@ export class IoSocketController {
return new MessageUserPosition(user.id, player.name, player.characterLayers, player.position);
}, users);
//console.warn('ANSWER PLAYER POSITIONS', listOfUsers);
if (answerFn === undefined && ALLOW_ARTILLERY === true) {
/*console.error("TYPEOF answerFn", typeof(answerFn));
console.error("answerFn", answerFn);
process.exit(1)*/
// For some reason, answerFn can be undefined if we use Artillery (?)
return;
}
answerFn(listOfUsers);
} catch (e) {
console.error('An error occurred on "join_room" event');
@ -244,7 +252,7 @@ export class IoSocketController {
const world = this.Worlds.get(Client.roomId);
if (!world) {
console.error("Could not find world with id '", Client.roomId, "'");
console.error("In SET_VIEWPORT, could not find world with id '", Client.roomId, "'");
return;
}
world.setViewport(Client, Client.viewport);
@ -255,7 +263,7 @@ export class IoSocketController {
});
socket.on(SockerIoEvent.USER_POSITION, (userMovesMessage: unknown): void => {
console.log(SockerIoEvent.USER_POSITION, userMovesMessage);
//console.log(SockerIoEvent.USER_POSITION, userMovesMessage);
try {
if (!isUserMovesInterface(userMovesMessage)) {
socket.emit(SockerIoEvent.MESSAGE_ERROR, {message: 'Invalid USER_POSITION message.'});
@ -272,7 +280,7 @@ export class IoSocketController {
// update position in the world
const world = this.Worlds.get(Client.roomId);
if (!world) {
console.error("Could not find world with id '", Client.roomId, "'");
console.error("In USER_POSITION, could not find world with id '", Client.roomId, "'");
return;
}
world.updatePosition(Client, Client.position);
@ -351,7 +359,7 @@ export class IoSocketController {
// update position in the world
const world = this.Worlds.get(Client.roomId);
if (!world) {
console.error("Could not find world with id '", Client.roomId, "'");
console.error("In SET_SILENT, could not find world with id '", Client.roomId, "'");
return;
}
world.setSilent(Client, silent);

View File

@ -28,6 +28,11 @@ scenarios:
y: 170
direction: 'down'
moving: false
viewport:
left: 500
top: 0
right: 800
bottom: 200
- think: 1
- loop:
- function: "setYRandom"

View File

@ -5,8 +5,13 @@ module.exports = {
};
function setYRandom(context, events, done) {
context.vars.x = (0 + Math.round(Math.random() * 1472));
context.vars.y = (0 + Math.round(Math.random() * 1090));
if (context.angle === undefined) {
context.angle = Math.random() * Math.PI * 2;
}
context.angle += 0.05;
context.vars.x = 320 + 1472/2 * (1 + Math.sin(context.angle));
context.vars.y = 200 + 1090/2 * (1 + Math.cos(context.angle));
context.vars.left = context.vars.x - 320;
context.vars.top = context.vars.y - 200;
context.vars.right = context.vars.x + 320;