Refactoring searchClientById
authorDavid Négrier <d.negrier@thecodingmachine.com>
Mon, 18 May 2020 16:33:04 +0000 (18:33 +0200)
committerDavid Négrier <d.negrier@thecodingmachine.com>
Mon, 18 May 2020 16:33:04 +0000 (18:33 +0200)
commite934015d87fea7d83cd8641e120bb8eec767570d
tree8ab467fe08d25af891686e34a535e08fbcf21315
parent2628373b56912ac186cdfe4861751fc9e9d290d8
Refactoring searchClientById

searchClientById was scanning through all open sockets to find the right one (which is inefficient if we have many).
Instead, I created a new Map that directly maps ids to sockets.
Furthermore, this solves a long-standing issue (when a socket is disconnected, we cannot find it anymore in the sockets list but it is still available in the disconnect callback from the map)
As a result, we should not have any remaining circles any more.
back/src/Controller/IoSocketController.ts
back/src/Model/World.ts