@netology-group/conference
Advanced tools
Comparing version 0.2.0-alpha.0 to 0.2.0
@@ -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=2)}([function(e,t,n){var r=n(3),i=n(4);e.exports=function(e,t,n){var o=t&&n||0;"string"==typeof e&&(t="binary"===e?new Array(16):null,e=null);var s=(e=e||{}).random||(e.rng||r)();if(s[6]=15&s[6]|64,s[8]=63&s[8]|128,t)for(var a=0;a<16;++a)t[o+a]=s[a];return t||i(s)}},function(e,t,n){"use strict";var r,i="object"==typeof Reflect?Reflect:null,o=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 s=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,o,s,a;if("function"!=typeof n)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof n);if(void 0===(o=e._events)?(o=e._events=Object.create(null),e._eventsCount=0):(void 0!==o.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),o=e._events),s=o[t]),void 0===s)s=o[t]=n,++e._eventsCount;else if("function"==typeof s?s=o[t]=r?[n,s]:[s,n]:r?s.unshift(n):s.push(n),0<(i=c(e))&&s.length>i&&!s.warned){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,a=u,console&&console.warn&&console.warn(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,o(this.listener,this.target,e))}.bind(r);return i.listener=n,r.wrapFn=i}function p(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 h(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||s(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||s(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 s;if(0<t.length&&(s=t[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var u=i[e];if(void 0===u)return!1;if("function"==typeof u)o(u,this,t);else{var c=u.length,f=d(u,c);for(n=0;n<c;++n)o(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,o,s;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,o=n.length-1;0<=o;o--)if(n[o]===t||n[o].listener===t){s=n[o].listener,i=o;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,s||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,o=Object.keys(n);for(r=0;r<o.length;++r)"removeListener"!==(i=o[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 p(this,e,!0)},a.prototype.rawListeners=function(e){return p(this,e,!1)},a.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):h.call(e,t)},a.prototype.listenerCount=h,a.prototype.eventNames=function(){return 0<this._eventsCount?r(this._events):[]}},function(e,t,n){e.exports=n(5)},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(0),i=n.n(r),o=n(1),s=n.n(o);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 s.a,this._messageHandler=r,this._mqtt=t,this._topic=n,this._handleMessageEvent=this._handleMessageEvent.bind(this),this._bindListeners(),this._addSubscription()}var t,n;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){if(e===this._topic){var n=this._messageHandler(e,t);null!==n&&this._ee.emit(n.type,n)}}},{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}();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,o){!function(t,n){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this),this._codec=i,this._mqtt=t,this._methods=o,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()}var t,n;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){return{type:"message",data:this._codec.decode(t)}}},{key:"_handleMessageEvent",value:function(e){var t=e.data,n=t.properties,r=t.payload,i=n.correlation_data,o=n.label,s=n.status,a=n.type;"response"===a&&i?200===s?this._processResponse("resolve",i,r):this._processResponse("reject",i,r):"event"===a&&"string"==typeof o?this._processNotification(o,r):console.debug("Unknown message",t)}},{key:"_processRequest",value:function(e,t){var n=this,r=i()(),o={properties:{type:"request",method:e,response_topic:this._topicIn,correlation_data:r},payload:JSON.stringify(t)},s=this._codec.encode(o);return this._mqtt.publish(this._topicOut,s,null,function(e){e&&n._processResponse("reject",r,e)}),new Promise(function(e,t){n._requestStorage[r]={payload:s,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:"destroy",value:function(){this._unbindListeners(),this._sub.destroy(),this._requestStorage={}}}])&&c(t.prototype,n),e}();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)}}function p(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=new(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}var t,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}())(function(e){return JSON.stringify(e)},function(e){var t,n;try{n={properties:(t=JSON.parse(e.toString())).properties,payload:JSON.parse(t.payload)}}catch(e){n={}}return n}),d=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=h,this._mqtt=t,this._rpc=new f(this._mqtt,this._topicIn,this._topicOut,this._codec,{}),this._subMessageHandler=this._subMessageHandler.bind(this)}var t,n;return t=e,(n=[{key:"createRoom",value:function(e,t){var n={time:e,audience:t};return this._rpc.send("room.create",n)}},{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:"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,t){var 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,t){var 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:"subscribeRoomEvents",value:function(e){return new u(this._mqtt,"apps/".concat(this._appName,"/api/v1/rooms/").concat(e,"/events"),this._subMessageHandler)}},{key:"_subMessageHandler",value:function(e,t){var n=this._codec.decode(t),r=n.properties,i=n.payload,o=r.label,s=null;return"event"===r.type&&void 0!==i?s={type:o,data:i}:console.debug("Unknown message",n),s}},{key:"destroy",value:function(){this._rpc.destroy()}}])&&p(t.prototype,n),e}();t.default=d}]).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=2)}([function(e,t,n){var r=n(3),i=n(4);e.exports=function(e,t,n){var o=t&&n||0;"string"==typeof e&&(t="binary"===e?new Array(16):null,e=null);var s=(e=e||{}).random||(e.rng||r)();if(s[6]=15&s[6]|64,s[8]=63&s[8]|128,t)for(var a=0;a<16;++a)t[o+a]=s[a];return t||i(s)}},function(e,t,n){"use strict";var r,i="object"==typeof Reflect?Reflect:null,o=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 s=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,o,s;if("function"!=typeof n)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof n);if(void 0===(o=e._events)?(o=e._events=Object.create(null),e._eventsCount=0):(void 0!==o.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),o=e._events),s=o[t]),void 0===s)s=o[t]=n,++e._eventsCount;else if("function"==typeof s?s=o[t]=r?[n,s]:[s,n]:r?s.unshift(n):s.push(n),0<(i=c(e))&&s.length>i&&!s.warned){s.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=e,a.type=t,a.count=s.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,o(this.listener,this.target,e))}.bind(r);return i.listener=n,r.wrapFn=i}function p(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 h(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||s(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||s(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 s;if(0<t.length&&(s=t[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var u=i[e];if(void 0===u)return!1;if("function"==typeof u)o(u,this,t);else{var c=u.length,f=d(u,c);for(n=0;n<c;++n)o(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,o,s;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,o=n.length-1;0<=o;o--)if(n[o]===t||n[o].listener===t){s=n[o].listener,i=o;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,s||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,o=Object.keys(n);for(r=0;r<o.length;++r)"removeListener"!==(i=o[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 p(this,e,!0)},a.prototype.rawListeners=function(e){return p(this,e,!1)},a.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):h.call(e,t)},a.prototype.listenerCount=h,a.prototype.eventNames=function(){return 0<this._eventsCount?r(this._events):[]}},function(e,t,n){e.exports=n(5)},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(0),i=n.n(r),o=n(1),s=n.n(o);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 s.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){if(e===this._topic){var n=this._messageHandler(e,t);null!==n&&this._ee.emit(n.type,n)}}},{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,o){!function(t,n){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this),this._codec=i,this._mqtt=t,this._methods=o,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){return{type:"message",data:this._codec.decode(t)}}},{key:"_handleMessageEvent",value:function(e){var t=e.data,n=t.properties,r=t.payload,i=n.correlation_data,o=n.label,s=n.status,a=n.type;"response"===a&&i?200===s?this._processResponse("resolve",i,r):this._processResponse("reject",i,r):"event"===a&&"string"==typeof o?this._processNotification(o,r):console.debug("Unknown message",t)}},{key:"_processRequest",value:function(e,t){var n=this,r=i()(),o={properties:{type:"request",method:e,response_topic:this._topicIn,correlation_data:r},payload:JSON.stringify(t)},s=this._codec.encode(o);return this._mqtt.publish(this._topicOut,s,null,function(e){e&&n._processResponse("reject",r,e)}),new Promise(function(e,t){n._requestStorage[r]={payload:s,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:"destroy",value:function(){this._unbindListeners(),this._sub.destroy(),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)}}function p(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=new(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}())(function(e){return JSON.stringify(e)},function(e){var t,n;try{n={properties:(t=JSON.parse(e.toString())).properties,payload:JSON.parse(t.payload)}}catch(e){n={}}return n}),d=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=h,this._mqtt=t,this._rpc=new f(this._mqtt,this._topicIn,this._topicOut,this._codec,{}),this._subMessageHandler=this._subMessageHandler.bind(this)}return t=e,(n=[{key:"createRoom",value:function(e,t){var n={time:e,audience:t};return this._rpc.send("room.create",n)}},{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:"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,t){var 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,t){var 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:"subscribeRoomEvents",value:function(e){return new u(this._mqtt,"apps/".concat(this._appName,"/api/v1/rooms/").concat(e,"/events"),this._subMessageHandler)}},{key:"_subMessageHandler",value:function(e,t){var n=this._codec.decode(t),r=n.properties,i=n.payload,o=r.label,s=null;return"event"===r.type&&void 0!==i?s={type:o,data:i}:console.debug("Unknown message",n),s}},{key:"destroy",value:function(){this._rpc.destroy()}}])&&p(t.prototype,n),e;var t,n}();t.default=d}]).default}); |
{ | ||
"name": "@netology-group/conference", | ||
"version": "0.2.0-alpha.0", | ||
"version": "0.2.0", | ||
"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
31156