Commit e3bd3fac authored by Tom Jorquera's avatar Tom Jorquera
Browse files

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) => { ...@@ -27,6 +27,10 @@ const create = (runner, modules, config) => {
const controller = { const controller = {
registry: {}, registry: {},
client: room => { client: room => {
if (room in controller.registry) {
return null;
}
controller.registry[room] = runner.run(modules, controller.registry[room] = runner.run(modules,
config.visio.url, config.visio.url,
room, room,
......
...@@ -48,4 +48,16 @@ describe('controller', () => { ...@@ -48,4 +48,16 @@ describe('controller', () => {
const client = controller.client('test'); const client = controller.client('test');
expect(controller.registry).toHaveProperty('test', client); 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