Files
Yi.Framework/Yi.Vue/src/util/signalR.js
2021-10-11 15:45:59 +08:00

34 lines
773 B
JavaScript
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
//引入安装的signalr包
import * as signalR from '@microsoft/signalr'
const signal = new signalR.HubConnectionBuilder()    //服务器地址
.withUrl([process.env.VUE_APP_BASE_API] + '/chat', {})
.build()
/* const signalr = function () {
var hub
if (hub === undefined) {
hub = signal
}
return hub
} */
// 自动重连
// async function start() {
// try {
// await signal.start()
// console.log('connected')
// } catch (err) {
// console.log(err)
// setTimeout(() => start(), 5000)
// }
// }
// signal.onclose(async() => {
// await start()
// })
// //将创建的signal赋值给Vue实例
export default {
install: function(Vue) {
Vue.prototype.signalr = signal
}
}