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