|
|
|
|
+(global["webpackJsonp"]=global["webpackJsonp"]||[]).push([["admin/chat/common/vendor"],{5868:function(e,t,n){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function i(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var c="ws://mall.huaml.com:8282",l={CART:1};Object.freeze(l);var a=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:c,t=new WebSocket(e);return t.onopen=function(e){console.log("websocket握手成功")},t.onmessage=function(e){var t;try{t=JSON.parse(e.data)}catch(e){t=e.data}var n=s.collection||{};Object.keys(n).forEach((function(e){var o=n[e];null!=o&&o.receive(t)}))},t.onclose=function(){console.log("连接关闭,定时重连")},t.onerror=function(){console.log("出现错误")},t},u=1e3,s=function(){function e(t,n,r){o(this,e),this.cb=n,this.filter=r,this._id=u++,this.types=[],this._register()}return i(e,[{key:"_register",value:function(){e.collection[this._id]=this}},{key:"_isNeedReceiveMessage",value:function(e,t,n,o){if(0==this.types.length)return!0;var r=this.types.findIndex((function(t){return t==e}));if(-1==r)return!1;if(!_.isFunction(this.filter))return!0;try{return this.filter.call(null,e,t,n,o)}catch(i){throw new Error(i)}}},{key:"receive",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.type,n=e.data,o=e.source,r=e.target,i=this._isNeedReceiveMessage(t,n,o,r);i&&this.cb.call(null,t,n,o,r)}}]),e}();s.collection={};var f=function(){var e,t;return{MESSAGE_TYPE:l,watch:function(n,o,r){return t=a(),e=new s(n,o,r),e},destroy:function(){t.close(),e=null,t=null}}},h=f;t.default=h}}]);
|