|
|
@ -46,45 +46,45 @@ class SocketConnection extends EventEmitter {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// async start(token) {
|
|
|
|
async start(token) {
|
|
|
|
// // 组件重新加载时, 如果 socket 存在, 不需要新建
|
|
|
|
// 组件重新加载时, 如果 socket 存在, 不需要新建
|
|
|
|
// if (!this.socket) {
|
|
|
|
if (!this.socket) {
|
|
|
|
// this.socket = new SignalR.HubConnectionBuilder()
|
|
|
|
console.log(this.socket)
|
|
|
|
// .configureLogging(SignalR.LogLevel.Information)
|
|
|
|
// this.socket = new SignalR.HubConnectionBuilder()
|
|
|
|
// .withUrl(
|
|
|
|
// .configureLogging(SignalR.LogLevel.Information)
|
|
|
|
// `/hubs/chathub`, {
|
|
|
|
// .withUrl(
|
|
|
|
// accessTokenFactory: () => token,
|
|
|
|
// `/hubs/chathub`, {
|
|
|
|
// skipNegotiation: true,
|
|
|
|
// accessTokenFactory: () => token,
|
|
|
|
// transport: SignalR.HttpTransportType.WebSockets
|
|
|
|
// skipNegotiation: true,
|
|
|
|
// }
|
|
|
|
// transport: SignalR.HttpTransportType.WebSockets
|
|
|
|
// )
|
|
|
|
// }
|
|
|
|
// .build()
|
|
|
|
// )
|
|
|
|
|
|
|
|
// .build()
|
|
|
|
// this.socket.on('ForceExist', () => { //可以做相关业务逻辑
|
|
|
|
this.socket.on('ForceExist', () => {
|
|
|
|
// store.dispatch("Logout").then(()=>{
|
|
|
|
//可以做相关业务逻辑
|
|
|
|
// window.location.reload()
|
|
|
|
store
|
|
|
|
// }).catch(err=>{
|
|
|
|
.dispatch('Logout')
|
|
|
|
// this.$message.error({
|
|
|
|
.then(() => {
|
|
|
|
// title: '错误',
|
|
|
|
window.location.reload()
|
|
|
|
// description: err.message
|
|
|
|
})
|
|
|
|
// })
|
|
|
|
.catch(err => {
|
|
|
|
// })
|
|
|
|
this.$message.error({
|
|
|
|
// })
|
|
|
|
title: '错误',
|
|
|
|
|
|
|
|
description: err.message
|
|
|
|
// this.socket.on('AppendNotice', (notice) => {
|
|
|
|
})
|
|
|
|
// store.commit("APPEND_NOTICE",notice)
|
|
|
|
})
|
|
|
|
// })
|
|
|
|
})
|
|
|
|
|
|
|
|
this.socket.on('AppendNotice', notice => {
|
|
|
|
// this.socket.onclose(async () => {
|
|
|
|
store.commit('APPEND_NOTICE', notice)
|
|
|
|
// this.offline = true
|
|
|
|
})
|
|
|
|
// this.emit('onclose')
|
|
|
|
this.socket.onclose(async () => {
|
|
|
|
// await this._initialize()
|
|
|
|
this.offline = true
|
|
|
|
// })
|
|
|
|
this.emit('onclose')
|
|
|
|
|
|
|
|
await this._initialize()
|
|
|
|
// await this._initialize()
|
|
|
|
})
|
|
|
|
|
|
|
|
await this._initialize()
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async authenticate(token) {
|
|
|
|
async authenticate(token) {
|
|
|
|
await this.start(token)
|
|
|
|
await this.start(token)
|
|
|
|