mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 21:06:06 +00:00
add reconnect for websocket
This commit is contained in:
@@ -4,13 +4,16 @@ import { v4 as uuidv4 } from 'uuid'
|
||||
class _RocketChatClientService {
|
||||
|
||||
connected = false
|
||||
hasPing = false
|
||||
private hasPing = false
|
||||
private firstPingFunx: Function
|
||||
|
||||
constructor() {}
|
||||
|
||||
private returns() {}
|
||||
|
||||
connect(firstPing: Function) {
|
||||
connect(firstPingFunx: Function) {
|
||||
this.hasPing = false
|
||||
this.firstPingFunx = firstPingFunx
|
||||
|
||||
this.ws.connect('wss://gabinetedigitalchat.dyndns.info/websocket');
|
||||
|
||||
@@ -27,7 +30,7 @@ class _RocketChatClientService {
|
||||
this.ws.send({msg:"pong"})
|
||||
if(this.hasPing == false) {
|
||||
// first ping
|
||||
firstPing()
|
||||
firstPingFunx()
|
||||
this.hasPing = true
|
||||
}
|
||||
}
|
||||
@@ -83,6 +86,11 @@ class _RocketChatClientService {
|
||||
deleteMessage() {}
|
||||
createRoom() {}
|
||||
|
||||
getRooms() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
subscribe() {
|
||||
var subscribeRequest = {
|
||||
"msg": "sub",
|
||||
@@ -168,11 +176,11 @@ class _RocketChatClientService {
|
||||
},
|
||||
|
||||
onclose:(event: any)=> {
|
||||
|
||||
this.connect(this.firstPingFunx())
|
||||
|
||||
this.connected = false
|
||||
console.log(`[close] Connection closed cleanly, code=${event.code} reason=${event.reason}`);
|
||||
setTimeout(()=>{
|
||||
// this.connect(this.url)
|
||||
}, 500)
|
||||
},
|
||||
|
||||
onerror: (event: any) => {
|
||||
|
||||
Reference in New Issue
Block a user