@netology-group/conference
Advanced tools
Comparing version 0.5.0 to 0.5.1
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Conference=t():e.Conference=t()}(window,function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=3)}([function(e,t,n){"use strict";var r,i="object"==typeof Reflect?Reflect:null,s=i&&"function"==typeof i.apply?i.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};r=i&&"function"==typeof i.ownKeys?i.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var o=Number.isNaN||function(e){return e!=e};function a(){a.init.call(this)}((e.exports=a).EventEmitter=a).prototype._events=void 0,a.prototype._eventsCount=0,a.prototype._maxListeners=void 0;var u=10;function c(e){return void 0===e._maxListeners?a.defaultMaxListeners:e._maxListeners}function f(e,t,n,r){var i,s,o;if("function"!=typeof n)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof n);if(void 0===(s=e._events)?(s=e._events=Object.create(null),e._eventsCount=0):(void 0!==s.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),s=e._events),o=s[t]),void 0===o)o=s[t]=n,++e._eventsCount;else if("function"==typeof o?o=s[t]=r?[n,o]:[o,n]:r?o.unshift(n):o.push(n),0<(i=c(e))&&o.length>i&&!o.warned){o.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=e,a.type=t,a.count=o.length,function(e){console&&console.warn&&console.warn(e)}(a)}return e}function l(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=function(){for(var e=[],t=0;t<arguments.length;t++)e.push(arguments[t]);this.fired||(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,s(this.listener,this.target,e))}.bind(r);return i.listener=n,r.wrapFn=i}function h(e,t,n){var r=e._events;if(void 0===r)return[];var i=r[t];return void 0===i?[]:"function"==typeof i?n?[i.listener||i]:[i]:n?function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(i):d(i,i.length)}function p(e){var t=this._events;if(void 0!==t){var n=t[e];if("function"==typeof n)return 1;if(void 0!==n)return n.length}return 0}function d(e,t){for(var n=new Array(t),r=0;r<t;++r)n[r]=e[r];return n}Object.defineProperty(a,"defaultMaxListeners",{enumerable:!0,get:function(){return u},set:function(e){if("number"!=typeof e||e<0||o(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");u=e}}),a.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},a.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||o(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},a.prototype.getMaxListeners=function(){return c(this)},a.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var r="error"===e,i=this._events;if(void 0!==i)r=r&&void 0===i.error;else if(!r)return!1;if(r){var o;if(0<t.length&&(o=t[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var u=i[e];if(void 0===u)return!1;if("function"==typeof u)s(u,this,t);else{var c=u.length,f=d(u,c);for(n=0;n<c;++n)s(f[n],this,t)}return!0},a.prototype.on=a.prototype.addListener=function(e,t){return f(this,e,t,!1)},a.prototype.prependListener=function(e,t){return f(this,e,t,!0)},a.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t);return this.on(e,l(this,e,t)),this},a.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t);return this.prependListener(e,l(this,e,t)),this},a.prototype.off=a.prototype.removeListener=function(e,t){var n,r,i,s,o;if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t);if(void 0===(r=this._events))return this;if(void 0===(n=r[e]))return this;if(n===t||n.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(i=-1,s=n.length-1;0<=s;s--)if(n[s]===t||n[s].listener===t){o=n[s].listener,i=s;break}if(i<0)return this;0===i?n.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(n,i),1===n.length&&(r[e]=n[0]),void 0!==r.removeListener&&this.emit("removeListener",e,o||t)}return this},a.prototype.removeAllListeners=function(e){var t,n,r;if(void 0===(n=this._events))return this;if(void 0===n.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==n[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete n[e]),this;if(0===arguments.length){var i,s=Object.keys(n);for(r=0;r<s.length;++r)"removeListener"!==(i=s[r])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(void 0!==t)for(r=t.length-1;0<=r;r--)this.removeListener(e,t[r]);return this},a.prototype.listeners=function(e){return h(this,e,!0)},a.prototype.rawListeners=function(e){return h(this,e,!1)},a.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):p.call(e,t)},a.prototype.listenerCount=p,a.prototype.eventNames=function(){return 0<this._eventsCount?r(this._events):[]}},function(e,t,n){var r=n(4),i=n(5);e.exports=function(e,t,n){var s=t&&n||0;"string"==typeof e&&(t="binary"===e?new Array(16):null,e=null);var o=(e=e||{}).random||(e.rng||r)();if(o[6]=15&o[6]|64,o[8]=63&o[8]|128,t)for(var a=0;a<16;++a)t[s+a]=o[a];return t||i(o)}},function(e,t,n){"use strict";var r="/",i="+",s="#";function o(e,t){for(var n=e.split(r),o=t.split(r),a=n.length,u=o.length,c=a-1,f=0;f<a;f++){var l=n[f],h=l[0],p=o[f];if(p||l){if(!p&&l!==s)return!1;if(h===s)return f===c;if(h!==i&&l!==p)return!1}}return a===u}function a(e,t){for(var n={},o=e.split(r),a=t.split(r),u=o.length,c=0;c<u;c++){var f=o[c],l=f[0];if(1!==f.length){if(l===s){n[f.slice(1)]=a.slice(c);break}l===i&&(n[f.slice(1)]=a[c])}}return n}e.exports={matches:o,extract:a,exec:function(e,t){return o(e,t)?a(e,t):null},fill:function(e,t){for(var n=e.split(r),o=n.length,a=[],u=0;u<o;u++){var c=n[u],f=c[0],l=t[c.slice(1)];if(f===s){void 0!==l&&a.push([].concat(l).join(r));break}f===i?a.push(""+l):a.push(c)}return a.join(r)},clean:function(e){for(var t=e.split(r),n=t.length,o=[],a=0;a<n;a++){var u=t[a],c=u[0];c===s?o.push(s):c===i?o.push(i):o.push(u)}return o.join("/")}}},function(e,t,n){e.exports=n(6)},function(e,t){var n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(n){var r=new Uint8Array(16);e.exports=function(){return n(r),r}}else{var i=new Array(16);e.exports=function(){for(var e,t=0;t<16;t++)0==(3&t)&&(e=4294967296*Math.random()),i[t]=e>>>((3&t)<<3)&255;return i}}},function(e,t){for(var n=[],r=0;r<256;++r)n[r]=(r+256).toString(16).substr(1);e.exports=function(e,t){var r=t||0,i=n;return[i[e[r++]],i[e[r++]],i[e[r++]],i[e[r++]],"-",i[e[r++]],i[e[r++]],"-",i[e[r++]],i[e[r++]],"-",i[e[r++]],i[e[r++]],"-",i[e[r++]],i[e[r++]],i[e[r++]],i[e[r++]],i[e[r++]],i[e[r++]]].join("")}},function(e,t,n){"use strict";n.r(t);var r=n(1),i=n.n(r),s=n(0),o=n.n(s);function a(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var u=function(){function e(t,n,r){!function(t,n){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this),this._ee=new o.a,this._messageHandler=r,this._mqtt=t,this._topic=n,this._handleMessageEvent=this._handleMessageEvent.bind(this),this._bindListeners(),this._addSubscription()}return t=e,(n=[{key:"_bindListeners",value:function(){this._mqtt.on("message",this._handleMessageEvent)}},{key:"_unbindListeners",value:function(){this._mqtt.off("message",this._handleMessageEvent)}},{key:"_addSubscription",value:function(){this._mqtt.subscribe(this._topic)}},{key:"_removeSubscription",value:function(){this._mqtt.unsubscribe(this._topic)}},{key:"_handleMessageEvent",value:function(e,t,n){if(e===this._topic){var r=this._messageHandler(e,t,n);null!==r&&this._ee.emit(r.type,r)}}},{key:"on",value:function(e,t){this._ee.addListener(e,t)}},{key:"off",value:function(e,t){this._ee.removeListener(e,t)}},{key:"destroy",value:function(){this._ee.removeAllListeners(),this._unbindListeners(),this._removeSubscription()}}])&&a(t.prototype,n),e;var t,n}();function c(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var f=function(){function e(t,n,r,i,s){!function(t,n){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this),this._codec=i,this._handlerMap={},this._incomingRequestMap={},this._mqtt=t,this._methods=s,this._requestStorage={},this._topicIn=n,this._topicOut=r,this._handleMessageEvent=this._handleMessageEvent.bind(this),this._subMessageHandler=this._subMessageHandler.bind(this),this._sub=new u(this._mqtt,this._topicIn,this._subMessageHandler),this._bindListeners()}return t=e,(n=[{key:"_bindListeners",value:function(){this._sub.on("message",this._handleMessageEvent)}},{key:"_unbindListeners",value:function(){this._sub.off("message",this._handleMessageEvent)}},{key:"_subMessageHandler",value:function(e,t,n){return{type:"message",data:{payload:this._codec.decode(t),properties:n.properties}}}},{key:"_handleMessageEvent",value:function(e){var t=e.data,n=t.properties,r=t.payload,i=n.correlationData,s=n.userProperties,o=s.label,a=s.method,u=s.status,c=s.type;"response"===c&&i?"200"===u?this._processResponse("resolve",i,r):this._processResponse("reject",i,r):"request"===c&&a&&i?this._processIncomingRequest(n,r):"event"===c&&"string"==typeof o?this._processNotification(o,r):console.debug("Unknown message",t)}},{key:"_processIncomingRequest",value:function(e,t){var n=e.correlationData,r=e.responseTopic,i=e.userProperties.method,s=this._handlerMap[i],o=null;if(s&&!this._incomingRequestMap[n]){this._incomingRequestMap[n]=!0,o=s(t);var a={correlationData:n,userProperties:{status:"200",type:"response"}};this._mqtt.publish(r,this._codec.encode(o),{properties:a})}}},{key:"_processRequest",value:function(e,t){var n=this,r=i()(),s={correlationData:r,responseTopic:this._topicIn,userProperties:{method:e,type:"request"}},o=this._codec.encode(t);return this._mqtt.publish(this._topicOut,o,{properties:s},function(e){e&&n._processResponse("reject",r,e)}),new Promise(function(e,t){n._requestStorage[r]={payload:o,resolve:e,reject:t}})}},{key:"_processResponse",value:function(e,t,n){var r=this._requestStorage[t];r?("resolve"===e?r.resolve(n):r.reject(n),delete this._requestStorage[t]):console.debug("Unknown response",t,n)}},{key:"_processNotification",value:function(e,t){var n=this._methods[e];n&&"function"==typeof n&&n(t)}},{key:"send",value:function(e,t){return this._processRequest(e,t)}},{key:"register",value:function(e,t){if(this._handlerMap[e])throw new Error("Method ".concat(e," already registered"));this._handlerMap[e]=t}},{key:"unregister",value:function(e){if(!this._handlerMap[e])throw new Error("Method ".concat(e," not registered"));delete this._handlerMap[e]}},{key:"destroy",value:function(){this._unbindListeners(),this._sub.destroy(),this._handlerMap={},this._incomingRequestMap={},this._requestStorage={}}}])&&c(t.prototype,n),e;var t,n}();function l(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var h=function(){function e(t,n){!function(t,n){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this),this._encoder=t,this._decoder=n}return t=e,(n=[{key:"encode",value:function(e){return this._encoder(e)}},{key:"decode",value:function(e){return this._decoder(e)}}])&&l(t.prototype,n),e;var t,n}(),p=n(2),d=n.n(p);function v(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var _=function(){function e(t,n,r){!function(t,n){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this),this._ee=new o.a,this._messageHandler=r,this._mqtt=t,this._topicPattern=n,this._handleMessageEvent=this._handleMessageEvent.bind(this),this._bindListeners()}return t=e,(n=[{key:"_bindListeners",value:function(){this._mqtt.on("message",this._handleMessageEvent)}},{key:"_unbindListeners",value:function(){this._mqtt.off("message",this._handleMessageEvent)}},{key:"_handleMessageEvent",value:function(e,t,n){if(null!==d.a.exec(this._topicPattern,e)){var r=this._messageHandler(e,t,n);null!==r&&this._ee.emit(r.type,r)}}},{key:"on",value:function(e,t){this._ee.addListener(e,t)}},{key:"off",value:function(e,t){this._ee.removeListener(e,t)}},{key:"destroy",value:function(){this._ee.removeAllListeners(),this._unbindListeners()}}])&&v(t.prototype,n),e;var t,n}();function y(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var m=new h(function(e){return JSON.stringify(e)},function(e){var t;try{t=JSON.parse(e.toString())}catch(e){t={}}return t}),g=function(){function e(t,n,r){!function(t,n){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this),this._agentId=n,this._appName=r,this._topicIn="agents/".concat(this._agentId,"/api/v1/in/").concat(this._appName),this._topicOut="agents/".concat(this._agentId,"/api/v1/out/").concat(this._appName),this._codec=m,this._mqtt=t,this._rpc=new f(this._mqtt,this._topicIn,this._topicOut,this._codec,{}),this._subMessageHandler=this._subMessageHandler.bind(this),this._mh=new _(this._mqtt,"apps/".concat(this._appName,"/api/v1/rooms/+roomId/events"),this._subMessageHandler)}return t=e,(n=[{key:"createRoom",value:function(e,t,n){var r={audience:t,backend:n,time:e};return this._rpc.send("room.create",r)}},{key:"readRoom",value:function(e){var t={id:e};return this._rpc.send("room.read",t)}},{key:"updateRoom",value:function(e,t,n){var r={id:e,time:t,audience:n};return this._rpc.send("room.update",r)}},{key:"deleteRoom",value:function(e){var t={id:e};return this._rpc.send("room.delete",t)}},{key:"enterRoom",value:function(e){var t={id:e};return this._rpc.send("room.enter",t)}},{key:"leaveRoom",value:function(e){var t={id:e};return this._rpc.send("room.leave",t)}},{key:"createRtc",value:function(e){var t={room_id:e};return this._rpc.send("rtc.create",t)}},{key:"readRtc",value:function(e){var t={id:e};return this._rpc.send("rtc.read",t)}},{key:"listRtc",value:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},n={room_id:e,offset:t.offset||0,limit:t.limit||25};return this._rpc.send("rtc.list",n)}},{key:"connectRtc",value:function(e){var t={id:e};return this._rpc.send("rtc.connect",t)}},{key:"createRtcSignal",value:function(e,t,n){var r={handle_id:e,jsep:t,label:n};return this._rpc.send("rtc_signal.create",r)}},{key:"listRtcStream",value:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},n={room_id:e,rtc_id:t.rtcId,offset:t.offset||0,limit:t.limit||25,time:t.time};return this._rpc.send("rtc_stream.list",n)}},{key:"createMessage",value:function(e,t,n){var r={room_id:e,agent_id:t,data:n};return this._rpc.send("message.create",r)}},{key:"listAgent",value:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},n={room_id:e,offset:t.offset||0,limit:t.limit||25};return this._rpc.send("agent.list",n)}},{key:"sendBroadcastMessage",value:function(e,t){var n={room_id:e,data:t};return this._rpc.send("message.broadcast",n)}},{key:"sendUnicastMessage",value:function(e,t,n){var r={room_id:e,agent_id:t,data:n};return this._rpc.send("message.unicast",r)}},{key:"subscribeRoomEvents",value:function(e){return new u(this._mqtt,"apps/".concat(this._appName,"/api/v1/rooms/").concat(e,"/events"),this._subMessageHandler)}},{key:"register",value:function(){var e;(e=this._rpc).register.apply(e,arguments)}},{key:"unregister",value:function(){var e;(e=this._rpc).unregister.apply(e,arguments)}},{key:"on",value:function(e,t){this._mh.on(e,t)}},{key:"off",value:function(e,t){this._mh.off(e,t)}},{key:"_subMessageHandler",value:function(e,t,n){var r=this._codec.decode(t),i=n.properties.userProperties,s=i.label,o=null;return"event"===i.type&&void 0!==r?o={type:s,data:r}:console.debug("Unknown message",e,t),o}},{key:"destroy",value:function(){this._mh.destroy(),this._rpc.destroy()}}])&&y(t.prototype,n),e;var t,n}();t.default=g}]).default}); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Conference=t():e.Conference=t()}(window,function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=3)}([function(e,t,n){"use strict";var r,i="object"==typeof Reflect?Reflect:null,s=i&&"function"==typeof i.apply?i.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};r=i&&"function"==typeof i.ownKeys?i.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var o=Number.isNaN||function(e){return e!=e};function a(){a.init.call(this)}((e.exports=a).EventEmitter=a).prototype._events=void 0,a.prototype._eventsCount=0,a.prototype._maxListeners=void 0;var u=10;function c(e){return void 0===e._maxListeners?a.defaultMaxListeners:e._maxListeners}function l(e,t,n,r){var i,s,o;if("function"!=typeof n)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof n);if(void 0===(s=e._events)?(s=e._events=Object.create(null),e._eventsCount=0):(void 0!==s.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),s=e._events),o=s[t]),void 0===o)o=s[t]=n,++e._eventsCount;else if("function"==typeof o?o=s[t]=r?[n,o]:[o,n]:r?o.unshift(n):o.push(n),0<(i=c(e))&&o.length>i&&!o.warned){o.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=e,a.type=t,a.count=o.length,function(e){console&&console.warn&&console.warn(e)}(a)}return e}function f(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=function(){for(var e=[],t=0;t<arguments.length;t++)e.push(arguments[t]);this.fired||(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,s(this.listener,this.target,e))}.bind(r);return i.listener=n,r.wrapFn=i}function h(e,t,n){var r=e._events;if(void 0===r)return[];var i=r[t];return void 0===i?[]:"function"==typeof i?n?[i.listener||i]:[i]:n?function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(i):d(i,i.length)}function p(e){var t=this._events;if(void 0!==t){var n=t[e];if("function"==typeof n)return 1;if(void 0!==n)return n.length}return 0}function d(e,t){for(var n=new Array(t),r=0;r<t;++r)n[r]=e[r];return n}Object.defineProperty(a,"defaultMaxListeners",{enumerable:!0,get:function(){return u},set:function(e){if("number"!=typeof e||e<0||o(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");u=e}}),a.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},a.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||o(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},a.prototype.getMaxListeners=function(){return c(this)},a.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var r="error"===e,i=this._events;if(void 0!==i)r=r&&void 0===i.error;else if(!r)return!1;if(r){var o;if(0<t.length&&(o=t[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var u=i[e];if(void 0===u)return!1;if("function"==typeof u)s(u,this,t);else{var c=u.length,l=d(u,c);for(n=0;n<c;++n)s(l[n],this,t)}return!0},a.prototype.on=a.prototype.addListener=function(e,t){return l(this,e,t,!1)},a.prototype.prependListener=function(e,t){return l(this,e,t,!0)},a.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t);return this.on(e,f(this,e,t)),this},a.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t);return this.prependListener(e,f(this,e,t)),this},a.prototype.off=a.prototype.removeListener=function(e,t){var n,r,i,s,o;if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t);if(void 0===(r=this._events))return this;if(void 0===(n=r[e]))return this;if(n===t||n.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(i=-1,s=n.length-1;0<=s;s--)if(n[s]===t||n[s].listener===t){o=n[s].listener,i=s;break}if(i<0)return this;0===i?n.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(n,i),1===n.length&&(r[e]=n[0]),void 0!==r.removeListener&&this.emit("removeListener",e,o||t)}return this},a.prototype.removeAllListeners=function(e){var t,n,r;if(void 0===(n=this._events))return this;if(void 0===n.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==n[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete n[e]),this;if(0===arguments.length){var i,s=Object.keys(n);for(r=0;r<s.length;++r)"removeListener"!==(i=s[r])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(void 0!==t)for(r=t.length-1;0<=r;r--)this.removeListener(e,t[r]);return this},a.prototype.listeners=function(e){return h(this,e,!0)},a.prototype.rawListeners=function(e){return h(this,e,!1)},a.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):p.call(e,t)},a.prototype.listenerCount=p,a.prototype.eventNames=function(){return 0<this._eventsCount?r(this._events):[]}},function(e,t,n){var r=n(4),i=n(5);e.exports=function(e,t,n){var s=t&&n||0;"string"==typeof e&&(t="binary"===e?new Array(16):null,e=null);var o=(e=e||{}).random||(e.rng||r)();if(o[6]=15&o[6]|64,o[8]=63&o[8]|128,t)for(var a=0;a<16;++a)t[s+a]=o[a];return t||i(o)}},function(e,t,n){"use strict";var r="/",i="+",s="#";function o(e,t){for(var n=e.split(r),o=t.split(r),a=n.length,u=o.length,c=a-1,l=0;l<a;l++){var f=n[l],h=f[0],p=o[l];if(p||f){if(!p&&f!==s)return!1;if(h===s)return l===c;if(h!==i&&f!==p)return!1}}return a===u}function a(e,t){for(var n={},o=e.split(r),a=t.split(r),u=o.length,c=0;c<u;c++){var l=o[c],f=l[0];if(1!==l.length){if(f===s){n[l.slice(1)]=a.slice(c);break}f===i&&(n[l.slice(1)]=a[c])}}return n}e.exports={matches:o,extract:a,exec:function(e,t){return o(e,t)?a(e,t):null},fill:function(e,t){for(var n=e.split(r),o=n.length,a=[],u=0;u<o;u++){var c=n[u],l=c[0],f=t[c.slice(1)];if(l===s){void 0!==f&&a.push([].concat(f).join(r));break}l===i?a.push(""+f):a.push(c)}return a.join(r)},clean:function(e){for(var t=e.split(r),n=t.length,o=[],a=0;a<n;a++){var u=t[a],c=u[0];c===s?o.push(s):c===i?o.push(i):o.push(u)}return o.join("/")}}},function(e,t,n){e.exports=n(6)},function(e,t){var n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(n){var r=new Uint8Array(16);e.exports=function(){return n(r),r}}else{var i=new Array(16);e.exports=function(){for(var e,t=0;t<16;t++)0==(3&t)&&(e=4294967296*Math.random()),i[t]=e>>>((3&t)<<3)&255;return i}}},function(e,t){for(var n=[],r=0;r<256;++r)n[r]=(r+256).toString(16).substr(1);e.exports=function(e,t){var r=t||0,i=n;return[i[e[r++]],i[e[r++]],i[e[r++]],i[e[r++]],"-",i[e[r++]],i[e[r++]],"-",i[e[r++]],i[e[r++]],"-",i[e[r++]],i[e[r++]],"-",i[e[r++]],i[e[r++]],i[e[r++]],i[e[r++]],i[e[r++]],i[e[r++]]].join("")}},function(e,t,n){"use strict";n.r(t);var r=n(1),i=n.n(r),s=n(0),o=n.n(s);function a(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var u=function(){function e(t,n,r){!function(t,n){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this),this._ee=new o.a,this._messageHandler=r,this._mqtt=t,this._topic=n,this._handleMessageEvent=this._handleMessageEvent.bind(this),this._bindListeners(),this._addSubscription()}return t=e,(n=[{key:"_bindListeners",value:function(){this._mqtt.on("message",this._handleMessageEvent)}},{key:"_unbindListeners",value:function(){this._mqtt.off("message",this._handleMessageEvent)}},{key:"_addSubscription",value:function(){this._mqtt.subscribe(this._topic)}},{key:"_removeSubscription",value:function(){this._mqtt.unsubscribe(this._topic)}},{key:"_handleMessageEvent",value:function(e,t,n){if(e===this._topic){var r=this._messageHandler(e,t,n);null!==r&&this._ee.emit(r.type,r)}}},{key:"on",value:function(e,t){this._ee.addListener(e,t)}},{key:"off",value:function(e,t){this._ee.removeListener(e,t)}},{key:"destroy",value:function(){this._ee.removeAllListeners(),this._unbindListeners(),this._removeSubscription()}}])&&a(t.prototype,n),e;var t,n}();function c(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var l=function(){function e(t,n,r,i,s){!function(t,n){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this),this._codec=i,this._handlerMap={},this._incomingRequestMap={},this._mqtt=t,this._methods=s,this._requestStorage={},this._topicIn=n,this._topicOut=r,this._handleMessageEvent=this._handleMessageEvent.bind(this),this._subMessageHandler=this._subMessageHandler.bind(this),this._sub=new u(this._mqtt,this._topicIn,this._subMessageHandler),this._bindListeners()}return t=e,(n=[{key:"_bindListeners",value:function(){this._sub.on("message",this._handleMessageEvent)}},{key:"_unbindListeners",value:function(){this._sub.off("message",this._handleMessageEvent)}},{key:"_subMessageHandler",value:function(e,t,n){return{type:"message",data:{payload:this._codec.decode(t),properties:n.properties}}}},{key:"_handleMessageEvent",value:function(e){var t=e.data,n=t.properties,r=t.payload,i=n.correlationData,s=n.userProperties,o=s.label,a=s.method,u=s.status,c=s.type;"response"===c&&i?"200"===u?this._processResponse("resolve",i,r):this._processResponse("reject",i,r):"request"===c&&a&&i?this._processIncomingRequest(n,r):"event"===c&&"string"==typeof o?this._processNotification(o,r):console.debug("Unknown message",t)}},{key:"_processIncomingRequest",value:function(e,t){var n=e.correlationData,r=e.responseTopic,i=e.userProperties.method,s=this._handlerMap[i],o=null;if(s&&!this._incomingRequestMap[n]){this._incomingRequestMap[n]=!0,o=s(t);var a={correlationData:n,userProperties:{local_timestamp:Date.now().toString(),status:"200",type:"response"}};this._mqtt.publish(r,this._codec.encode(o),{properties:a})}}},{key:"_processRequest",value:function(e,t){var n=this,r=i()(),s={correlationData:r,responseTopic:this._topicIn,userProperties:{local_timestamp:Date.now().toString(),method:e,type:"request"}},o=this._codec.encode(t);return this._mqtt.publish(this._topicOut,o,{properties:s},function(e){e&&n._processResponse("reject",r,e)}),new Promise(function(e,t){n._requestStorage[r]={payload:o,resolve:e,reject:t}})}},{key:"_processResponse",value:function(e,t,n){var r=this._requestStorage[t];r?("resolve"===e?r.resolve(n):r.reject(n),delete this._requestStorage[t]):console.debug("Unknown response",t,n)}},{key:"_processNotification",value:function(e,t){var n=this._methods[e];n&&"function"==typeof n&&n(t)}},{key:"send",value:function(e,t){return this._processRequest(e,t)}},{key:"register",value:function(e,t){if(this._handlerMap[e])throw new Error("Method ".concat(e," already registered"));this._handlerMap[e]=t}},{key:"unregister",value:function(e){if(!this._handlerMap[e])throw new Error("Method ".concat(e," not registered"));delete this._handlerMap[e]}},{key:"destroy",value:function(){this._unbindListeners(),this._sub.destroy(),this._handlerMap={},this._incomingRequestMap={},this._requestStorage={}}}])&&c(t.prototype,n),e;var t,n}();function f(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var h=function(){function e(t,n){!function(t,n){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this),this._encoder=t,this._decoder=n}return t=e,(n=[{key:"encode",value:function(e){return this._encoder(e)}},{key:"decode",value:function(e){return this._decoder(e)}}])&&f(t.prototype,n),e;var t,n}(),p=n(2),d=n.n(p);function v(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var _=function(){function e(t,n,r){!function(t,n){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this),this._ee=new o.a,this._messageHandler=r,this._mqtt=t,this._topicPattern=n,this._handleMessageEvent=this._handleMessageEvent.bind(this),this._bindListeners()}return t=e,(n=[{key:"_bindListeners",value:function(){this._mqtt.on("message",this._handleMessageEvent)}},{key:"_unbindListeners",value:function(){this._mqtt.off("message",this._handleMessageEvent)}},{key:"_handleMessageEvent",value:function(e,t,n){if(null!==d.a.exec(this._topicPattern,e)){var r=this._messageHandler(e,t,n);null!==r&&this._ee.emit(r.type,r)}}},{key:"on",value:function(e,t){this._ee.addListener(e,t)}},{key:"off",value:function(e,t){this._ee.removeListener(e,t)}},{key:"destroy",value:function(){this._ee.removeAllListeners(),this._unbindListeners()}}])&&v(t.prototype,n),e;var t,n}();function y(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var m=new h(function(e){return JSON.stringify(e)},function(e){var t;try{t=JSON.parse(e.toString())}catch(e){t={}}return t}),g=function(){function e(t,n,r){!function(t,n){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this),this._agentId=n,this._appName=r,this._topicIn="agents/".concat(this._agentId,"/api/v1/in/").concat(this._appName),this._topicOut="agents/".concat(this._agentId,"/api/v1/out/").concat(this._appName),this._codec=m,this._mqtt=t,this._rpc=new l(this._mqtt,this._topicIn,this._topicOut,this._codec,{}),this._subMessageHandler=this._subMessageHandler.bind(this),this._mh=new _(this._mqtt,"apps/".concat(this._appName,"/api/v1/rooms/+roomId/events"),this._subMessageHandler)}return t=e,(n=[{key:"createRoom",value:function(e,t,n){var r={audience:t,backend:n,time:e};return this._rpc.send("room.create",r)}},{key:"readRoom",value:function(e){var t={id:e};return this._rpc.send("room.read",t)}},{key:"updateRoom",value:function(e,t,n){var r={id:e,time:t,audience:n};return this._rpc.send("room.update",r)}},{key:"deleteRoom",value:function(e){var t={id:e};return this._rpc.send("room.delete",t)}},{key:"enterRoom",value:function(e){var t={id:e};return this._rpc.send("room.enter",t)}},{key:"leaveRoom",value:function(e){var t={id:e};return this._rpc.send("room.leave",t)}},{key:"createRtc",value:function(e){var t={room_id:e};return this._rpc.send("rtc.create",t)}},{key:"readRtc",value:function(e){var t={id:e};return this._rpc.send("rtc.read",t)}},{key:"listRtc",value:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},n={room_id:e,offset:t.offset||0,limit:t.limit||25};return this._rpc.send("rtc.list",n)}},{key:"connectRtc",value:function(e){var t={id:e};return this._rpc.send("rtc.connect",t)}},{key:"createRtcSignal",value:function(e,t,n){var r={handle_id:e,jsep:t,label:n};return this._rpc.send("rtc_signal.create",r)}},{key:"listRtcStream",value:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},n={room_id:e,rtc_id:t.rtcId,offset:t.offset||0,limit:t.limit||25,time:t.time};return this._rpc.send("rtc_stream.list",n)}},{key:"createMessage",value:function(e,t,n){var r={room_id:e,agent_id:t,data:n};return this._rpc.send("message.create",r)}},{key:"listAgent",value:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},n={room_id:e,offset:t.offset||0,limit:t.limit||25};return this._rpc.send("agent.list",n)}},{key:"sendBroadcastMessage",value:function(e,t){var n={room_id:e,data:t};return this._rpc.send("message.broadcast",n)}},{key:"sendUnicastMessage",value:function(e,t,n){var r={room_id:e,agent_id:t,data:n};return this._rpc.send("message.unicast",r)}},{key:"subscribeRoomEvents",value:function(e){return new u(this._mqtt,"apps/".concat(this._appName,"/api/v1/rooms/").concat(e,"/events"),this._subMessageHandler)}},{key:"register",value:function(){var e;(e=this._rpc).register.apply(e,arguments)}},{key:"unregister",value:function(){var e;(e=this._rpc).unregister.apply(e,arguments)}},{key:"on",value:function(e,t){this._mh.on(e,t)}},{key:"off",value:function(e,t){this._mh.off(e,t)}},{key:"_subMessageHandler",value:function(e,t,n){var r=this._codec.decode(t),i=n.properties.userProperties,s=i.label,o=null;return"event"===i.type&&void 0!==r?o={type:s,data:r}:console.debug("Unknown message",e,t),o}},{key:"destroy",value:function(){this._mh.destroy(),this._rpc.destroy()}}])&&y(t.prototype,n),e;var t,n}();t.default=g}]).default}); |
@@ -107,2 +107,3 @@ "use strict"; | ||
userProperties: { | ||
local_timestamp: Date.now().toString(), | ||
status: '200', | ||
@@ -128,2 +129,3 @@ type: 'response' | ||
userProperties: { | ||
local_timestamp: Date.now().toString(), | ||
method: method, | ||
@@ -130,0 +132,0 @@ type: 'request' |
{ | ||
"name": "@netology-group/conference", | ||
"version": "0.5.0", | ||
"version": "0.5.1", | ||
"description": "JavaScript API-client for Conference service", | ||
@@ -5,0 +5,0 @@ "files": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
42430
631