Commit e3bd3fac authored by Tom Jorquera's avatar Tom Jorquera

lib: controller now check for existing registered clients

The server controller now check that there is no client registered for the given
room before creating one.
parent 29ef0ae4
Pipeline #4469 passed with stage
in 38 seconds
......@@ -27,6 +27,10 @@ const create = (runner, modules, config) => {
const controller = {
registry: {},
client: room => {
if (room in controller.registry) {
return null;
}
controller.registry[room] = runner.run(modules,
config.visio.url,
room,
......
......@@ -48,4 +48,16 @@ describe('controller', () => {
const client = controller.client('test');
expect(controller.registry).toHaveProperty('test', client);
});
test('should return null when trying to create a client for an existing room', () => {
controller.client('test');
const client2 = controller.client('test');
expect(client2).toBeNull();
});
test('should not replace the client for an existing room', () => {
const client1 = controller.client('test');
controller.client('test');
expect(controller.registry).toHaveProperty('test', client1);
});
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment