"use strict";var cov_23dx4yj8lc=function(){var path="/Users/josh.burman/Projects/braid/dist/server/channels/channelBase.js";var hash="4324e691c77bcb76d072a60488fe83f4a0292ea5";var Function=function(){}.constructor;var global=new Function("return this")();var gcv="__coverage__";var coverageData={path:"/Users/josh.burman/Projects/braid/dist/server/channels/channelBase.js",statementMap:{"0":{start:{line:2,column:0},end:{line:2,column:62}},"1":{start:{line:3,column:13},end:{line:3,column:33}},"2":{start:{line:6,column:8},end:{line:6,column:26}},"3":{start:{line:7,column:8},end:{line:7,column:21}},"4":{start:{line:8,column:8},end:{line:8,column:68}},"5":{start:{line:11,column:8},end:{line:19,column:9}},"6":{start:{line:12,column:12},end:{line:12,column:113}},"7":{start:{line:13,column:12},end:{line:13,column:88}},"8":{start:{line:16,column:12},end:{line:16,column:38}},"9":{start:{line:17,column:12},end:{line:17,column:106}},"10":{start:{line:18,column:12},end:{line:18,column:70}},"11":{start:{line:22,column:8},end:{line:26,column:9}},"12":{start:{line:23,column:12},end:{line:25,column:13}},"13":{start:{line:24,column:16},end:{line:24,column:30}},"14":{start:{line:27,column:8},end:{line:27,column:20}},"15":{start:{line:30,column:8},end:{line:38,column:9}},"16":{start:{line:31,column:12},end:{line:37,column:13}},"17":{start:{line:32,column:16},end:{line:32,column:40}},"18":{start:{line:33,column:16},end:{line:33,column:86}},"19":{start:{line:36,column:16},end:{line:36,column:105}},"20":{start:{line:42,column:0},end:{line:42,column:30}}},fnMap:{"0":{name:"(anonymous_0)",decl:{start:{line:5,column:4},end:{line:5,column:5}},loc:{start:{line:5,column:20},end:{line:9,column:5}},line:5},"1":{name:"(anonymous_1)",decl:{start:{line:10,column:4},end:{line:10,column:5}},loc:{start:{line:10,column:22},end:{line:20,column:5}},line:10},"2":{name:"(anonymous_2)",decl:{start:{line:21,column:4},end:{line:21,column:5}},loc:{start:{line:21,column:21},end:{line:28,column:5}},line:21},"3":{name:"(anonymous_3)",decl:{start:{line:29,column:4},end:{line:29,column:5}},loc:{start:{line:29,column:36},end:{line:39,column:5}},line:29}},branchMap:{"0":{loc:{start:{line:11,column:8},end:{line:19,column:9}},type:"if",locations:[{start:{line:11,column:8},end:{line:19,column:9}},{start:{line:11,column:8},end:{line:19,column:9}}],line:11},"1":{loc:{start:{line:23,column:12},end:{line:25,column:13}},type:"if",locations:[{start:{line:23,column:12},end:{line:25,column:13}},{start:{line:23,column:12},end:{line:25,column:13}}],line:23},"2":{loc:{start:{line:31,column:12},end:{line:37,column:13}},type:"if",locations:[{start:{line:31,column:12},end:{line:37,column:13}},{start:{line:31,column:12},end:{line:37,column:13}}],line:31}},s:{"0":0,"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0},f:{"0":0,"1":0,"2":0,"3":0},b:{"0":[0,0],"1":[0,0],"2":[0,0]},_coverageSchema:"43e27e138ebf9cfc5966b082cf9a028302ed4184"};var coverage=global[gcv]||(global[gcv]={});if(coverage[path]&&coverage[path].hash===hash){return coverage[path];}coverageData.hash=hash;return coverage[path]=coverageData;}();cov_23dx4yj8lc.s[0]++;Object.defineProperty(exports,"__esModule",{value:true});var logger=(cov_23dx4yj8lc.s[1]++,require('../logger'));class ChannelBase{constructor(id){cov_23dx4yj8lc.f[0]++;cov_23dx4yj8lc.s[2]++;this.clients=[];cov_23dx4yj8lc.s[3]++;this.id=id;cov_23dx4yj8lc.s[4]++;logger.accessLog.info('Channel Created',{channelId:id});}addClient(client){cov_23dx4yj8lc.f[1]++;cov_23dx4yj8lc.s[5]++;if(this.clientExists(client.id)){cov_23dx4yj8lc.b[0][0]++;cov_23dx4yj8lc.s[6]++;logger.errorLog.info('Client already exits in channel',{channelId:this.id,clientId:client.id});cov_23dx4yj8lc.s[7]++;return{'status':'notice','message':'client aleady exists in channel'};}else{cov_23dx4yj8lc.b[0][1]++;cov_23dx4yj8lc.s[8]++;this.clients.push(client);cov_23dx4yj8lc.s[9]++;logger.accessLog.info('Added client to channel',{channelId:this.id,clientId:client.id});cov_23dx4yj8lc.s[10]++;return{'status':'success','message':'client added'};}}clientExists(id){cov_23dx4yj8lc.f[2]++;cov_23dx4yj8lc.s[11]++;for(let client of this.clients){cov_23dx4yj8lc.s[12]++;if(client.id==id){cov_23dx4yj8lc.b[1][0]++;cov_23dx4yj8lc.s[13]++;return client;}else{cov_23dx4yj8lc.b[1][1]++;}}cov_23dx4yj8lc.s[14]++;return null;}broadcastMessage(from,message){cov_23dx4yj8lc.f[3]++;cov_23dx4yj8lc.s[15]++;for(let client of this.clients){cov_23dx4yj8lc.s[16]++;if(client!=from){cov_23dx4yj8lc.b[2][0]++;cov_23dx4yj8lc.s[17]++;client.ws.send(message);cov_23dx4yj8lc.s[18]++;logger.accessLog.info(`sent to ${client.id}: `,{message:message});}else{cov_23dx4yj8lc.b[2][1]++;cov_23dx4yj8lc.s[19]++;logger.accessLog.info(`client is same as sender: ${client.id} - `,{message:message});}}}};cov_23dx4yj8lc.s[20]++;exports.default=ChannelBase;//# sourceMappingURL=channelBase.js.map