|
|
@@ -1,5 +1,5 @@
|
|
|
// import { url } from '@src/utils/axios'
|
|
|
-const DEFAULT_ADDRESS = process.env.NODE_ENV === 'production' ? 'ws://saas.api.beiface.com:1313' : 'http://api.m.huaml.com/chat/begin'
|
|
|
+const DEFAULT_ADDRESS = process.env.NODE_ENV === 'production' ? 'ws://m.huaml.com:8282' : 'ws://m.huaml.com:8282'
|
|
|
|
|
|
const TYPE = {
|
|
|
CART: 1
|
|
|
@@ -59,30 +59,18 @@ class Watcher {
|
|
|
this.filter = filter
|
|
|
this._id = watcherId++
|
|
|
this.types = []
|
|
|
- this._isVaildTypes(types)
|
|
|
|
|
|
this._register()
|
|
|
}
|
|
|
- _isVaildTypes(types) {
|
|
|
- if (_.isArray(types)) {
|
|
|
- types.forEach(type => {
|
|
|
- this._isVaildTypes(type)
|
|
|
- })
|
|
|
- } else {
|
|
|
- let valid = isValidType(types)
|
|
|
- if (!valid) throw new Error(`types item is invalid (null or String), current type is ${type}`)
|
|
|
- }
|
|
|
- if (types != null && types != '') this.types.push(types)
|
|
|
- }
|
|
|
|
|
|
_register() {
|
|
|
Watcher.collection[this._id] = this
|
|
|
}
|
|
|
|
|
|
- _destroy() {
|
|
|
- let collection = Watcher.collection
|
|
|
- collection[this._id] = null
|
|
|
- }
|
|
|
+ // _destroy() {
|
|
|
+ // let collection = Watcher.collection
|
|
|
+ // collection[this._id] = null
|
|
|
+ // }
|
|
|
_isNeedReceiveMessage(type, data, source, target) {
|
|
|
if (this.types.length == 0) return true
|
|
|
let index = this.types.findIndex(_type => {
|
|
|
@@ -121,7 +109,7 @@ const handler = () => {
|
|
|
return watcher
|
|
|
},
|
|
|
destroy() {
|
|
|
- watcher._destroy()
|
|
|
+ // watcher._destroy()
|
|
|
ws.close()
|
|
|
watcher = null
|
|
|
ws = null
|