WXL (wul)
9 小时以前 1feb410410781eb56159c8fdd856e68d2c23e0a4
1
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-4eeccb30"],{"10eb":function(t,e,n){var s,i,o;n("eb88").default;n("6678"),n("a5a2"),n("6e70"),n("c33f"),n("cfee"),n("aad4"),function(n,r){i=[],s=r,o="function"===typeof s?s.apply(e,i):s,void 0===o||(t.exports=o)}(0,(function(){"use strict";function t(t,e){if(!e)return t;for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t}function e(e){var n={autoReconnect:!0,maxReconnectAttempts:5,debug:!0};this.options=t({},n),this.options=t(this.options,e||{}),this.websocket=null,this.isLoggedIn=!1,this.currentCall=null,this.seatInfo={},this.eventHandlers={},this.init()}return e.prototype={init:function(){this.setupEventHandlers()},setupEventHandlers:function(){this.on("login_success",this.handleLoginSuccess.bind(this)),this.on("login_failed",this.handleLoginFailed.bind(this)),this.on("call_start",this.handleCallStart.bind(this)),this.on("call_end",this.handleCallEnd.bind(this)),this.on("seat_status_change",this.handleSeatStatusChange.bind(this))},connect:function(t){try{return"undefined"===typeof CTIWebSocket?(this.trigger("error",{type:"dependency_error",message:"CTIWebSocket未定义"}),!1):(this.websocket=new CTIWebSocket({url:t,debug:this.options.debug,reconnectInterval:3e3,maxReconnectAttempts:this.options.maxReconnectAttempts}),this.bindWebSocketEvents(),!0)}catch(e){return this.trigger("error",{type:"connection_error",error:e}),!1}},bindWebSocketEvents:function(){var t=this;this.websocket.on("open",(function(){t.trigger("connected")})),this.websocket.on("close",(function(){t.isLoggedIn=!1,t.trigger("disconnected")})),this.websocket.on("error",(function(e){t.trigger("error",e)})),this.websocket.on("cti:system:keepalive",(function(e){t.trigger("keepalive",e)})),this.websocket.on("cti:control:tp_callin",(function(e){t.trigger("call_incoming",e),e.uuid&&t.trigger("uuid_received",e.uuid)}))},login:function(t,e,n){return this.websocket&&this.websocket.isConnected?this.websocket.seatlogin(t,e,n):(this.trigger("error",{type:"not_connected",message:"WebSocket未连接"}),!1)},logout:function(){if(this.websocket&&this.isLoggedIn){var t=this.websocket.seatlogout(this.seatInfo.seatname,this.seatInfo.seatnum);return t&&(this.isLoggedIn=!1,this.seatInfo={}),t}return!1},makeCall:function(t){return this.isLoggedIn?this.websocket.callout(this.seatInfo.seatname,this.seatInfo.seatnum,t):(this.trigger("error",{type:"not_logged_in",message:"坐席未登录"}),!1)},hangupCall:function(t){if(!this.isLoggedIn)return!1;var e=t||(this.currentCall?this.currentCall.uuid:"");return this.websocket.hangup(this.seatInfo.seatname,this.seatInfo.seatnum,e)},setAfk:function(){return!!this.isLoggedIn&&this.websocket.afk(this.seatInfo.seatname,this.seatInfo.seatnum)},setOnline:function(){return!!this.isLoggedIn&&this.websocket.online(this.seatInfo.seatname,this.seatInfo.seatnum)},on:function(t,e){this.eventHandlers[t]||(this.eventHandlers[t]=[]),this.eventHandlers[t].push(e)},off:function(t,e){if(this.eventHandlers[t]){var n=this.eventHandlers[t].indexOf(e);n>-1&&this.eventHandlers[t].splice(n,1)}},trigger:function(t,e){this.eventHandlers[t]&&this.eventHandlers[t].forEach((function(t){"function"===typeof t&&t(e)}))},destroy:function(){this.websocket&&(this.websocket.close(),this.websocket=null),this.eventHandlers={}}},e}))},eb88:function(t,e,n){function s(e){return t.exports=s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t.exports.__esModule=!0,t.exports["default"]=t.exports,s(e)}n("7520"),n("ec0b"),n("58c6"),n("cfee"),n("f76b"),n("21e8"),t.exports=s,t.exports.__esModule=!0,t.exports["default"]=t.exports}}]);