"use strict";var cov_13t9hk2g1o=function(){var path="/Users/josh.burman/Projects/braid/dist/server/channelManager.js";var hash="4088549a18f57065120b3ac3ef79933cc87f67aa";var Function=function(){}.constructor;var global=new Function("return this")();var gcv="__coverage__";var coverageData={path:"/Users/josh.burman/Projects/braid/dist/server/channelManager.js",statementMap:{"0":{start:{line:2,column:0},end:{line:2,column:62}},"1":{start:{line:3,column:22},end:{line:3,column:55}},"2":{start:{line:4,column:13},end:{line:4,column:32}},"3":{start:{line:7,column:8},end:{line:7,column:27}},"4":{start:{line:9,column:22},end:{line:9,column:58}},"5":{start:{line:10,column:8},end:{line:10,column:36}},"6":{start:{line:13,column:28},end:{line:13,column:60}},"7":{start:{line:15,column:8},end:{line:23,column:9}},"8":{start:{line:16,column:12},end:{line:16,column:36}},"9":{start:{line:17,column:12},end:{line:17,column:75}},"10":{start:{line:20,column:12},end:{line:20,column:53}},"11":{start:{line:21,column:12},end:{line:21,column:40}},"12":{start:{line:22,column:12},end:{line:22,column:85}},"13":{start:{line:24,column:8},end:{line:24,column:23}},"14":{start:{line:27,column:8},end:{line:31,column:9}},"15":{start:{line:28,column:12},end:{line:30,column:13}},"16":{start:{line:29,column:16},end:{line:29,column:31}},"17":{start:{line:32,column:8},end:{line:32,column:20}},"18":{start:{line:35,column:22},end:{line:35,column:52}},"19":{start:{line:36,column:8},end:{line:44,column:9}},"20":{start:{line:37,column:12},end:{line:37,column:38}},"21":{start:{line:38,column:12},end:{line:38,column:45}},"22":{start:{line:39,column:12},end:{line:39,column:43}},"23":{start:{line:42,column:12},end:{line:42,column:83}},"24":{start:{line:43,column:12},end:{line:43,column:102}},"25":{start:{line:47,column:8},end:{line:56,column:9}},"26":{start:{line:48,column:26},end:{line:48,column:90}},"27":{start:{line:49,column:12},end:{line:49,column:121}},"28":{start:{line:50,column:12},end:{line:50,column:45}},"29":{start:{line:53,column:12},end:{line:53,column:36}},"30":{start:{line:54,column:12},end:{line:54,column:76}},"31":{start:{line:55,column:12},end:{line:55,column:59}},"32":{start:{line:60,column:0},end:{line:60,column:33}}},fnMap:{"0":{name:"(anonymous_0)",decl:{start:{line:6,column:4},end:{line:6,column:5}},loc:{start:{line:6,column:18},end:{line:11,column:5}},line:6},"1":{name:"(anonymous_1)",decl:{start:{line:12,column:4},end:{line:12,column:5}},loc:{start:{line:12,column:24},end:{line:25,column:5}},line:12},"2":{name:"(anonymous_2)",decl:{start:{line:26,column:4},end:{line:26,column:5}},loc:{start:{line:26,column:30},end:{line:33,column:5}},line:26},"3":{name:"(anonymous_3)",decl:{start:{line:34,column:4},end:{line:34,column:5}},loc:{start:{line:34,column:43},end:{line:45,column:5}},line:34},"4":{name:"(anonymous_4)",decl:{start:{line:46,column:4},end:{line:46,column:5}},loc:{start:{line:46,column:30},end:{line:57,column:5}},line:46}},branchMap:{"0":{loc:{start:{line:15,column:8},end:{line:23,column:9}},type:"if",locations:[{start:{line:15,column:8},end:{line:23,column:9}},{start:{line:15,column:8},end:{line:23,column:9}}],line:15},"1":{loc:{start:{line:28,column:12},end:{line:30,column:13}},type:"if",locations:[{start:{line:28,column:12},end:{line:30,column:13}},{start:{line:28,column:12},end:{line:30,column:13}}],line:28},"2":{loc:{start:{line:36,column:8},end:{line:44,column:9}},type:"if",locations:[{start:{line:36,column:8},end:{line:44,column:9}},{start:{line:36,column:8},end:{line:44,column:9}}],line:36}},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,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0},f:{"0":0,"1":0,"2":0,"3":0,"4":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_13t9hk2g1o.s[0]++;Object.defineProperty(exports,"__esModule",{value:true});const channelBase_1=(cov_13t9hk2g1o.s[1]++,require("./channels/channelBase"));var logger=(cov_13t9hk2g1o.s[2]++,require('./logger'));class ChannelManager{constructor(){cov_13t9hk2g1o.f[0]++;cov_13t9hk2g1o.s[3]++;this.channels=[];// create default channel...
var channel=(cov_13t9hk2g1o.s[4]++,new channelBase_1.default('default'));cov_13t9hk2g1o.s[5]++;this.channels.push(channel);}createChannel(data){cov_13t9hk2g1o.f[1]++;var channelExists=(cov_13t9hk2g1o.s[6]++,this.channelExists(data.channel));var channel;cov_13t9hk2g1o.s[7]++;if(channelExists){cov_13t9hk2g1o.b[0][0]++;cov_13t9hk2g1o.s[8]++;channel=channelExists;cov_13t9hk2g1o.s[9]++;logger.accessLog.info(`Channel already exists: ${channel.id}`);}else{cov_13t9hk2g1o.b[0][1]++;cov_13t9hk2g1o.s[10]++;channel=this.createByChannelType(data);cov_13t9hk2g1o.s[11]++;this.channels.push(channel);cov_13t9hk2g1o.s[12]++;logger.accessLog.info(`Added channel to channel manager: ${channel.id}`);}cov_13t9hk2g1o.s[13]++;return channel;}channelExists(channel_id){cov_13t9hk2g1o.f[2]++;cov_13t9hk2g1o.s[14]++;for(let channel of this.channels){cov_13t9hk2g1o.s[15]++;if(channel.id==channel_id){cov_13t9hk2g1o.b[1][0]++;cov_13t9hk2g1o.s[16]++;return channel;}else{cov_13t9hk2g1o.b[1][1]++;}}cov_13t9hk2g1o.s[17]++;return null;}addClientToChannel(client,channel_id){cov_13t9hk2g1o.f[3]++;var channel=(cov_13t9hk2g1o.s[18]++,this.channelExists(channel_id));cov_13t9hk2g1o.s[19]++;if(channel){cov_13t9hk2g1o.b[2][0]++;cov_13t9hk2g1o.s[20]++;channel.addClient(client);cov_13t9hk2g1o.s[21]++;client.connectToChannel(channel);cov_13t9hk2g1o.s[22]++;return{'status':'success'};}else{cov_13t9hk2g1o.b[2][1]++;cov_13t9hk2g1o.s[23]++;logger.accessLog.info(`channel with id ${channel_id} does not exist.`);cov_13t9hk2g1o.s[24]++;return{'status':'notice','message':`channel with id ${channel_id} does not exist.`};}}createByChannelType(data){cov_13t9hk2g1o.f[4]++;cov_13t9hk2g1o.s[25]++;try{var Channel=(cov_13t9hk2g1o.s[26]++,require(`./channels/${data.client_type}s/${data.client}channel`));cov_13t9hk2g1o.s[27]++;logger.accessLog.info(`attempting to create channel of type ${data.client}, channel id: ${data.channel}...`);cov_13t9hk2g1o.s[28]++;return new Channel(data.channel);}catch(e){cov_13t9hk2g1o.s[29]++;logger.errorLog.info(e);cov_13t9hk2g1o.s[30]++;logger.accessLog.info(`creating base channel: ${data.channel}`);cov_13t9hk2g1o.s[31]++;return new channelBase_1.default(data.channel);}}};cov_13t9hk2g1o.s[32]++;exports.default=ChannelManager;// { :client => 'mhs', :client_type => 'site', :user_id => 125, :user_type => 'user', :channel => 'mhs_1239' }
//# sourceMappingURL=channelManager.js.map