nuxt-plugins-grpc-web-client-stream
v2.0.9
Published
grpc-web client stream && retry
Downloads
63
Maintainers
Readme
nuxt-plugins-grpc-web-client-stream
Install
npm i nuxt-plugins-grpc-web-client-stream
Props
service request grpc metadata (选填) host
Usage
import subscribeEvents from 'nuxt-plugins-grpc-web-client-stream'
async beforeStream() {
let host = 'https://dengji.wenjuant.com'
try {
await subscribeEvents(
{
service: CaseMgm.SubscribeEvent,
SubscribeEventRequest,
grpc,
host,
},
{
onMsgFun: this.onMsgFun,
onUnknownFun: this.onUnknownFun,
}
)
} catch (error) {
if (error.status) {
console.log('重连失败,请检查网络链接!')
}
}
},
onMsgFun(val) {
console.log(val, '这是接收长链接返回信息的位置')
},
onUnknownFun(val) {
this.notify({
content: '由于长时间未执行操作,与服务器的链接已断开!',
type: 'error',
})
}