File manager - Edit - /home/web/vm-3fadc827.na4u.ru/www/bitrix/modules/im/install/js/im/call/engine.min.js
Back
(function(){BX.namespace("BX.Call");BX.Call.State={Idle:"Idle",Proceeding:"Proceeding",Connected:"Connected",Finished:"Finished"};BX.Call.UserState={Idle:"Idle",Busy:"Busy",Calling:"Calling",Unavailable:"Unavailable",Declined:"Declined",Ready:"Ready",Connecting:"Connecting",Connected:"Connected",Failed:"Failed"};BX.Call.EndpointDirection={SendOnly:"send",RecvOnly:"recv",SendRecv:"sendrecv"};BX.Call.Type={Instant:1,Permanent:2};BX.Call.Provider={Plain:"Plain",Voximplant:"Voximplant"};BX.Call.StreamTag={Main:"main",Screen:"screen"};BX.Call.Direction={Incoming:"Incoming",Outgoing:"Outgoing"};BX.Call.Quality={VeryHigh:"very_high",High:"high",Medium:"medium",Low:"low",VeryLow:"very_low"};BX.Call.UserMnemonic={all:"all",none:"none"};BX.Call.Event={onUserInvited:"onUserInvited",onUserStateChanged:"onUserStateChanged",onUserMicrophoneState:"onUserMicrophoneState",onUserCameraState:"onUserCameraState",onUserVideoPaused:"onUserVideoPaused",onUserScreenState:"onUserScreenState",onUserRecordState:"onUserRecordState",onUserVoiceStarted:"onUserVoiceStarted",onUserVoiceStopped:"onUserVoiceStopped",onUserFloorRequest:"onUserFloorRequest",onUserEmotion:"onUserEmotion",onCustomMessage:"onCustomMessage",onLocalMediaReceived:"onLocalMediaReceived",onLocalMediaStopped:"onLocalMediaStopped",onMicrophoneLevel:"onMicrophoneLevel",onDeviceListUpdated:"onDeviceListUpdated",onRTCStatsReceived:"onRTCStatsReceived",onCallFailure:"onCallFailure",onRemoteMediaReceived:"onRemoteMediaReceived",onRemoteMediaStopped:"onRemoteMediaStopped",onNetworkProblem:"onNetworkProblem",onReconnecting:"onReconnecting",onReconnected:"onReconnected",onJoin:"onJoin",onLeave:"onLeave",onDestroy:"onDestroy"};var e={createCall:"im.call.create",createChildCall:"im.call.createChildCall",getPublicChannels:"pull.channel.public.list",getCall:"im.call.get"};var t=false;BX.Call.Engine=function(){this.debugFlag=false;if(!t){throw new Error("Do not use this constructor directly, use BX.Call.Engine.getInstance instead")}this.calls={};this.userId=Number(BX.message("USER_ID"));this.siteId="";this.unknownCalls={};this.restClient=null;this.pullClient=null;this.init()};BX.Call.Engine.getInstance=function(){return BX.CallEngine};BX.Call.Engine.prototype.init=function(){BX.addCustomEvent("onPullEvent-im",this.__onPullEvent.bind(this));BX.addCustomEvent("onPullClientEvent-im",this.__onPullClientEvent.bind(this))};BX.Call.Engine.prototype.getSiteId=function(){return this.siteId||BX.message("SITE_ID")||""};BX.Call.Engine.prototype.setSiteId=function(e){this.siteId=e};BX.Call.Engine.prototype.getCurrentUserId=function(){return this.userId};BX.Call.Engine.prototype.setCurrentUserId=function(e){this.userId=Number(e)};BX.Call.Engine.prototype.setRestClient=function(e){this.restClient=e};BX.Call.Engine.prototype.setPullClient=function(e){this.pullClient=e};BX.Call.Engine.prototype.getRestClient=function(){return this.restClient||BX.rest};BX.Call.Engine.prototype.getPullClient=function(){return this.pullClient||BX.PULL};BX.Call.Engine.prototype.getLogService=function(){return BX.message("call_log_service")};BX.Call.Engine.prototype.createCall=function(t){var n=this;return new Promise(function(i,a){var o=t.type||BX.Call.Type.Instant;var r=t.provider||n.getDefaultProvider();if(t.joinExisting){for(var s in n.calls){if(n.calls.hasOwnProperty(s)){var c=n.calls[s];if(c.provider==t.provider&&c.associatedEntity.type==t.entityType&&c.associatedEntity.id==t.entityId){n.log(s,"Found existing call, attaching to it");return i({call:c,isNew:false})}}}}var d={type:o,provider:r,entityType:t.entityType,entityId:t.entityId,joinExisting:!!t.joinExisting,userIds:BX.type.isArray(t.userIds)?t.userIds:[]};n.getRestClient().callMethod(e.createCall,d).then(function(e){if(e.error()){var o=e.error().getError();return a({code:o.error,message:o.error_description})}var r=e.data();if(r.userData){BX.Call.Util.setUserData(r.userData)}if(r.publicChannels){BX.CallEngine.getPullClient().setPublicIds(Object.values(r.publicChannels))}var s=r.call;if(n.calls[s["ID"]]){if(n.calls[s["ID"]]instanceof l){n.calls[s["ID"]].destroy()}else{console.error("Call "+s["ID"]+" already exists");return i({call:n.calls[s["ID"]],isNew:false})}}var c=n.__getCallFabric(s["PROVIDER"]);var d=c.createCall({id:parseInt(s["ID"],10),instanceId:n.getUuidv4(),direction:BX.Call.Direction.Outgoing,users:r.users,videoEnabled:t.videoEnabled==true,enableMicAutoParameters:t.enableMicAutoParameters!==false,associatedEntity:s.ASSOCIATED_ENTITY,type:s.TYPE,startDate:s.START_DATE,events:{onDestroy:n.__onCallDestroy.bind(n)},debug:t.debug===true,logToken:r.logToken});n.calls[s["ID"]]=d;if(r.isNew){n.log(d.id,"Creating new call")}else{n.log(d.id,"Server returned existing call, attaching to it")}BX.onCustomEvent(window,"CallEvents::callCreated",[{call:d}]);i({call:d,isNew:r.isNew})}).catch(function(e){if(BX.type.isFunction(e.error)){e=e.error().getError()}a({code:e.error,message:e.error_description})})})};BX.Call.Engine.prototype.createChildCall=function(t,l,n){var i=this;return new Promise(function(a,o){if(!i.calls[t]){return o("Parent call is not found")}var r=i.calls[t];var s={parentId:t,newProvider:l,newUsers:n};i.getRestClient().callMethod(e.createChildCall,s,function(e){var t=e.data();var l=t.call;var n=i.__getCallFabric(l["PROVIDER"]);var o=n.createCall({id:parseInt(l["ID"],10),instanceId:i.getUuidv4(),parentId:l["PARENT_ID"],direction:BX.Call.Direction.Outgoing,users:t.users,videoEnabled:r.isVideoEnabled(),enableMicAutoParameters:r.enableMicAutoParameters!==false,associatedEntity:l.ASSOCIATED_ENTITY,type:l.TYPE,startDate:l.START_DATE,events:{onDestroy:i.__onCallDestroy.bind(i)},logToken:t.logToken});i.calls[l["ID"]]=o;BX.onCustomEvent(window,"CallEvents::callCreated",[{call:o}]);a({call:o,isNew:t.isNew})})})};BX.Call.Engine.prototype._instantiateCall=function(e,t,l){if(this.calls[e["ID"]]){console.error("Call "+e["ID"]+" already exists");return this.calls[e["ID"]]}var n=this.__getCallFabric(e["PROVIDER"]);var i=n.createCall({id:parseInt(e["ID"],10),instanceId:this.getUuidv4(),initiatorId:parseInt(e["INITIATOR_ID"],10),parentId:e["PARENT_ID"],direction:e["INITIATOR_ID"]==this.userId?BX.Call.Direction.Outgoing:BX.Call.Direction.Incoming,users:t,associatedEntity:e.ASSOCIATED_ENTITY,type:e.TYPE,startDate:e["START_DATE"],logToken:l,events:{onDestroy:this.__onCallDestroy.bind(this)}});this.calls[e["ID"]]=i;BX.onCustomEvent(window,"CallEvents::callCreated",[{call:i}]);return i};BX.Call.Engine.prototype.getCallWithId=function(t){var l=this;return new Promise(function(n,i){if(l.calls[t]){return n({call:l.calls[t],isNew:false})}l.getRestClient().callMethod(e.getCall,{callId:t}).then(function(e){var t=e.data();n({call:l._instantiateCall(t.call,t.users,t.logToken),isNew:false})}).catch(function(e){console.error(e);if(BX.type.isFunction(e.error)){e=e.error().getError()}i({code:e.error,message:e.error_description})})})};BX.Call.Engine.prototype.getUuidv4=function(){return BX.Call.Util.getUuidv4()};BX.Call.Engine.prototype.__onPullEvent=function(e,t,l){var n={"Call::incoming":this.__onPullIncomingCall.bind(this)};if(e.startsWith("Call::")){if(t.publicIds){BX.CallEngine.getPullClient().setPublicIds(Object.values(t.publicIds))}if(t.userData){BX.Call.Util.setUserData(t.userData)}}if(n[e]){n[e].call(this,t,l)}else if(e.substr(0,6)==="Call::"&&(t["call"]||t["callId"])){var i=t["call"]?t["call"]["ID"]:t["callId"];if(this.calls[i]){this.calls[i].__onPullEvent(e,t,l)}else if(e==="Call::ping"){this.__onUnknownCallPing(t,l).then(function(n){if(n&&this.calls[i]){this.calls[i].__onPullEvent(e,t,l)}}.bind(this))}}};BX.Call.Engine.prototype.__onPullClientEvent=function(e,t,l){if(e.substr(0,6)==="Call::"&&t["callId"]){var n=t["callId"];if(this.calls[n]){this.calls[n].__onPullEvent(e,t,l)}else if(e==="Call::ping"){this.__onUnknownCallPing(t,l).then(function(i){if(i&&this.calls[n]){this.calls[n].__onPullEvent(e,t,l)}}.bind(this))}}};BX.Call.Engine.prototype.__onPullIncomingCall=function(e,t){if(t.server_time_ago>30){console.error("Call was started too long time ago");return}var l=e.call;var n=parseInt(l.ID,10);var i;if(e.publicIds){BX.CallEngine.getPullClient().setPublicIds(Object.values(e.publicIds))}if(e.userData){BX.Call.Util.setUserData(e.userData)}if(this.calls[n]){i=this.calls[n]}else{var a=this.__getCallFabric(l.PROVIDER);i=a.createCall({id:n,instanceId:this.getUuidv4(),parentId:l.PARENT_ID||null,callFromMobile:e.isLegacyMobile===true,direction:BX.Call.Direction.Incoming,users:e.users,initiatorId:e.senderId,associatedEntity:l.ASSOCIATED_ENTITY,type:l.TYPE,startDate:l.START_DATE,logToken:e.logToken,events:{onDestroy:this.__onCallDestroy.bind(this)}});this.calls[n]=i;BX.onCustomEvent(window,"CallEvents::callCreated",[{call:i}])}i.addInvitedUsers(e.invitedUsers);if(i){BX.onCustomEvent(window,"CallEvents::incomingCall",[{call:i,video:e.video===true,isLegacyMobile:e.isLegacyMobile===true}])}this.log(i.id,"Incoming call "+i.id)};BX.Call.Engine.prototype.__onUnknownCallPing=function(e,t){return new Promise(function(l,n){var i=Number(e.callId);if(t.server_time_ago>10){this.log(i,"Error: Ping was sent too long time ago");return l(false)}if(!this.__isCallAppInitialized()){return l(false)}if(this.unknownCalls[i]){return l(false)}this.unknownCalls[i]=true;if(e.userData){BX.Call.Util.setUserData(e.userData)}this.getCallWithId(i).then(function(e){this.unknownCalls[i]=false;l(true)}.bind(this)).catch(function(e){this.unknownCalls[i]=false;this.log(i,"Error: Could not instantiate call",e);l(false)}.bind(this))}.bind(this))};BX.Call.Engine.prototype.__onCallDestroy=function(e){var t=e.call.id;this.calls[t]=new l({callId:t,onDelete:function(){if(this.calls[t]){delete this.calls[t]}}.bind(this)});BX.onCustomEvent(window,"CallEvents::callDestroyed",[{callId:e.call.id}])};BX.Call.Engine.prototype.__isCallAppInitialized=function(){if("BXIM"in window){return BXIM.init}else if(BX.Messenger&&BX.Messenger.Application&&BX.Messenger.Application.conference){return BX.Messenger.Application.conference.inited}return false};BX.Call.Engine.prototype.getDefaultProvider=function(){return BX.Call.Provider.Plain};BX.Call.Engine.prototype.getConferencePageTag=function(e){return"conference-open-"+e};BX.Call.Engine.prototype.__getCallFabric=function(e){if(e==BX.Call.Provider.Plain){return BX.Call.PlainCallFabric}else if(e==BX.Call.Provider.Voximplant){return BX.Call.VoximplantCallFabric}throw new Error("Unknown call provider type "+e)};BX.Call.Engine.prototype.debug=function(e){this.debugFlag=typeof e==="undefined"?true:!!e;return this.debugFlag};BX.Call.Engine.prototype.log=function(){var e=BX.Call.Util.getLogMessage.call(BX.Call.Util,arguments);if(BX.desktop&&BX.desktop.ready()){BX.desktop.log(BX.message("USER_ID")+".video.log",e)}if(this.debugFlag){if(console){var t=["Call log ["+BX.Call.Util.getTimeForLog()+"]: "];console.log.apply(this,t.concat(Array.prototype.slice.call(arguments)))}}};BX.Call.Engine.prototype.getAllowedVideoQuality=function(e){if(e<5){return BX.Call.Quality.VeryHigh}else if(e<10){return BX.Call.Quality.High}else if(e<16){return BX.Call.Quality.Medium}else if(e<32){return BX.Call.Quality.Low}else{return BX.Call.Quality.VeryLow}};BX.Call.PlainCallFabric={createCall:function(e){return new BX.Call.PlainCall(e)}};BX.Call.VoximplantCallFabric={createCall:function(e){return new BX.Call.VoximplantCall(e)}};var l=function(e){this.callId=e.callId;this.lifetime=e.lifetime||120;this.callbacks={onDelete:BX.type.isFunction(e.onDelete)?e.onDelete:BX.DoNothing};this.deleteTimeout=setTimeout(function(){this.callbacks.onDelete({callId:this.callId})}.bind(this),this.lifetime*1e3)};l.prototype.__onPullEvent=function(e,t,l){};l.prototype.isAnyoneParticipating=function(){return false};l.prototype.addEventListener=function(){return false};l.prototype.removeEventListener=function(){return false};l.prototype.destroy=function(){clearTimeout(this.deleteTimeout);this.callbacks.onDelete=BX.DoNothing};t=true;BX.CallEngine=new BX.Call.Engine;t=false})(); //# sourceMappingURL=engine.map.js
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.24 |
proxy
|
phpinfo
|
Settings