added unit testing, and started implementing unit tests...phew

This commit is contained in:
Josh Burman
2019-03-12 22:28:02 -04:00
parent 74aad4a957
commit e8c2539f1b
3489 changed files with 464813 additions and 88 deletions

View File

@ -1,6 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const clientBase_1 = require("./clients/clientBase");
var logger = require('./logger');
class ClientManager {
constructor() {
this.clients = [];
@ -10,11 +11,11 @@ class ClientManager {
if (data.client_type && !this.clientExists(data.user_id)) {
var client = this.getClientType(data, ws);
this.clients.push(client);
console.log('client added to client manager');
logger.accessLog.info(`client added to client manager: ${data.user_id}`);
return client;
}
else {
console.log('no client type designated or client already exists, socket disconnected.');
logger.accessLog.info(`no client type designated or client already exists, socket disconnected: ${data.user_id}`);
ws.close();
return null;
}
@ -45,7 +46,7 @@ class ClientManager {
if (client.id == id) {
client.ws.close();
this.clients.splice(index, 1);
console.log('client disconnected');
logger.accessLog.info(`client disconnected: ${client.id}`);
return true;
}
index++;
@ -54,12 +55,12 @@ class ClientManager {
getClientType(data, ws) {
try {
var Client = require(`./clients/${data.client_type}s/${data.client}client`);
console.log(`attempting to create client of type ${data.client}, client id: ${data.user_id}...`);
logger.accessLog.info(`attempting to create client of type ${data.client}, client id: ${data.user_id}...`);
return new Client(data, ws);
}
catch (e) {
console.log(e);
console.log(`creating base client`);
logger.errorLog.info(e);
logger.accessLog.info(`creating base client: ${data.user_id}`);
return new clientBase_1.default(data, ws);
}
}