|  | @ -11,46 +11,48 @@ var log = require('../../util/log');
 | 
												
													
														
															|  | var clientCache = null;
 |  | var clientCache = null;
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | class ClientCache {
 |  | class ClientCache {
 | 
												
													
														
															|  |     constructor(){
 |  | 
 | 
												
													
														
															|  | 
 |  |     constructor() {
 | 
												
													
														
															|  |         this._clientsBySocket = new Map();
 |  |         this._clientsBySocket = new Map();
 | 
												
													
														
															|  |         this._clientsByUserId = new Map();
 |  |         this._clientsByUserId = new Map();
 | 
												
													
														
															|  |     }
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |     get clients(){
 |  | 
 | 
												
													
														
															|  | 
 |  |     get clients() {
 | 
												
													
														
															|  |         return this._clientsByUserId;
 |  |         return this._clientsByUserId;
 | 
												
													
														
															|  |     }
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |     addClient(client){
 |  | 
 | 
												
													
														
															|  | 
 |  |     addClient(client) {
 | 
												
													
														
															|  |         this._clientsByUserId.set(client.userId, client);
 |  |         this._clientsByUserId.set(client.userId, client);
 | 
												
													
														
															|  |         this._clientsBySocket.set(client.socket, client);
 |  |         this._clientsBySocket.set(client.socket, client);
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |         //log.info('Current clients: ', this.clients);
 |  |         //log.info('Current clients: ', this.clients);
 | 
												
													
														
															|  |     }
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |     removeByUserId(userId){
 |  | 
 | 
												
													
														
															|  | 
 |  |     removeByUserId(userId) {
 | 
												
													
														
															|  |         var socket = this.findById(userId);
 |  |         var socket = this.findById(userId);
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |         this._clientsByUserId.delete(userId);
 |  |         this._clientsByUserId.delete(userId);
 | 
												
													
														
															|  |         this._clientsBySocket.delete(socket);
 |  |         this._clientsBySocket.delete(socket);
 | 
												
													
														
															|  |     }
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |     removeByUserSocket(socket){
 |  | 
 | 
												
													
														
															|  |         var userId = this.findBySocket(socket);
 |  | 
 | 
												
													
														
															|  | 
 |  |     removeByUserSocket(socket) {
 | 
												
													
														
															|  | 
 |  |         var client = this.findBySocket(socket);
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |         this._clientsByUserId.delete(userId);
 |  | 
 | 
												
													
														
															|  |         this._clientsBySocket.delete(socket);
 |  | 
 | 
												
													
														
															|  | 
 |  |         if (client) {
 | 
												
													
														
															|  | 
 |  |             this._clientsByUserId.delete(client.userId);
 | 
												
													
														
															|  | 
 |  |             this._clientsBySocket.delete(socket);
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  |     }
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |     findById(userId){
 |  | 
 | 
												
													
														
															|  | 
 |  |     findById(userId) {
 | 
												
													
														
															|  |         return this._clientsByUserId.get(userId);
 |  |         return this._clientsByUserId.get(userId);
 | 
												
													
														
															|  |     }
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |     findBySocket(socket){
 |  | 
 | 
												
													
														
															|  | 
 |  |     findBySocket(socket) {
 | 
												
													
														
															|  |         return this._clientsBySocket.get(socket);
 |  |         return this._clientsBySocket.get(socket);
 | 
												
													
														
															|  |     }
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |     static clientCache(){
 |  | 
 | 
												
													
														
															|  |         if(clientCache === null){
 |  | 
 | 
												
													
														
															|  | 
 |  |     static clientCache() {
 | 
												
													
														
															|  | 
 |  |         if (clientCache === null) {
 | 
												
													
														
															|  |             clientCache = new ClientCache();
 |  |             clientCache = new ClientCache();
 | 
												
													
														
															|  |         }
 |  |         }
 | 
												
													
														
															|  | 
 |  | 
 |