-
Notifications
You must be signed in to change notification settings - Fork 188
/
publisher.js.map
1 lines (1 loc) · 3.12 KB
/
publisher.js.map
1
{"version":3,"sources":["../../src/components/publisher.js"],"names":["Configurable","require","Component","axon","portfinder","module","exports","advertisement","discoveryOptions","sock","types","type","on","startDiscovery","onPort","err","port","bind","server","code","getPort","host","address","topic","data","namespace","emit"],"mappings":";;;;;;;;;;AAAA,IAAMA,eAAeC,QAAQ,gBAAR,CAArB;AACA,IAAMC,YAAYD,QAAQ,aAAR,CAAlB;AACA,IAAME,OAAOF,QAAQ,gBAAR,CAAb;AACA,IAAMG,aAAaH,QAAQ,YAAR,CAAnB;;AAEAI,OAAOC,OAAP;AAAA;;AACI,uBAAYC,aAAZ,EAA2BC,gBAA3B,EAA6C;AAAA;;AAAA,0HACnCD,aADmC,EACpBC,gBADoB;;AAGzC,cAAKC,IAAL,GAAY,IAAIN,KAAKO,KAAL,CAAW,MAAKC,IAAhB,CAAJ,EAAZ;AACA,cAAKF,IAAL,CAAUA,IAAV,CAAeG,EAAf,CAAkB,MAAlB,EAA0B;AAAA,mBAAM,MAAKC,cAAL,EAAN;AAAA,SAA1B;;AAEA,YAAMC,SAAS,SAATA,MAAS,CAACC,GAAD,EAAMC,IAAN,EAAe;AAC1B,kBAAKT,aAAL,CAAmBS,IAAnB,GAA0B,CAACA,IAA3B;;AAEA,kBAAKP,IAAL,CAAUQ,IAAV,CAAeD,IAAf;AACA,kBAAKP,IAAL,CAAUA,IAAV,CAAeS,MAAf,CAAsBN,EAAtB,CAAyB,OAAzB,EAAkC,UAACG,GAAD,EAAS;AACvC,oBAAIA,IAAII,IAAJ,IAAY,YAAhB,EAA8B,MAAMJ,GAAN;;AAE9BX,2BAAWgB,OAAX,CAAmB;AACfC,0BAAM,MAAKb,gBAAL,CAAsBc,OADb;AAEfN,0BAAM,MAAKT,aAAL,CAAmBS;AAFV,iBAAnB,EAGGF,MAHH;AAIH,aAPD;AAQH,SAZD;;AAcAV,mBAAWgB,OAAX,CAAmB;AACfC,kBAAM,MAAKb,gBAAL,CAAsBc,OADb;AAEfN,kBAAMT,cAAcS;AAFL,SAAnB,EAGGF,MAHH;AApByC;AAwB5C;;AAzBL;AAAA;AAAA,gCA2BYS,KA3BZ,EA2BmBC,IA3BnB,EA2ByB;AACjB,gBAAIC,YAAY,EAAhB;;AAEA,gBAAI,KAAKlB,aAAL,CAAmBkB,SAAvB,EAAkC;AAC9BA,4BAAY,KAAKlB,aAAL,CAAmBkB,SAAnB,GAA+B,IAA3C;AACH;;AAEDF,oBAAQ,cAAcE,SAAd,GAA0BF,KAAlC;AACA,iBAAKd,IAAL,CAAUiB,IAAV,CAAeH,KAAf,EAAsBC,IAAtB;AACH;AApCL;AAAA;AAAA,4BAsCe;AACP,mBAAO,aAAP;AACH;AAxCL;AAAA;AAAA,4BA0Ce;AACP,mBAAO,aAAP;AACH;AA5CL;;AAAA;AAAA,EAAyCxB,aAAaE,SAAb,CAAzC","file":"publisher.js","sourcesContent":["const Configurable = require('./configurable');\nconst Component = require('./component');\nconst axon = require('@dashersw/axon');\nconst portfinder = require('portfinder');\n\nmodule.exports = class Publisher extends Configurable(Component) {\n constructor(advertisement, discoveryOptions) {\n super(advertisement, discoveryOptions);\n\n this.sock = new axon.types[this.type]();\n this.sock.sock.on('bind', () => this.startDiscovery());\n\n const onPort = (err, port) => {\n this.advertisement.port = +port;\n\n this.sock.bind(port);\n this.sock.sock.server.on('error', (err) => {\n if (err.code != 'EADDRINUSE') throw err;\n\n portfinder.getPort({\n host: this.discoveryOptions.address,\n port: this.advertisement.port,\n }, onPort);\n });\n };\n\n portfinder.getPort({\n host: this.discoveryOptions.address,\n port: advertisement.port,\n }, onPort);\n }\n\n publish(topic, data) {\n let namespace = '';\n\n if (this.advertisement.namespace) {\n namespace = this.advertisement.namespace + '::';\n }\n\n topic = 'message::' + namespace + topic;\n this.sock.emit(topic, data);\n };\n\n get type() {\n return 'pub-emitter';\n }\n\n get oppo() {\n return 'sub-emitter';\n }\n};\n"]}