mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 21:06:06 +00:00
Imrpove websocket inicial connect
This commit is contained in:
@@ -4,14 +4,15 @@ import { v4 as uuidv4 } from 'uuid'
|
||||
class _RocketChatClientService {
|
||||
|
||||
connected = false
|
||||
hasPing = false
|
||||
|
||||
constructor() {}
|
||||
|
||||
private returns() {}
|
||||
|
||||
connect(url = 'wss://gabinetedigitalchat.dyndns.info/websocket') {
|
||||
connect(firstPing: Function) {
|
||||
|
||||
this.ws.connect(url);
|
||||
this.ws.connect('wss://gabinetedigitalchat.dyndns.info/websocket');
|
||||
|
||||
const connectMessage = {
|
||||
msg: "connect",
|
||||
@@ -20,10 +21,15 @@ class _RocketChatClientService {
|
||||
}
|
||||
|
||||
this.ws.send(connectMessage)
|
||||
|
||||
|
||||
this.ws.registerCallback('Onmessage',(message: any) => {
|
||||
if(message.msg == "ping") {
|
||||
this.ws.send({msg:"pong"})
|
||||
if(this.hasPing == false) {
|
||||
// first ping
|
||||
firstPing()
|
||||
this.hasPing = true
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -51,7 +57,7 @@ class _RocketChatClientService {
|
||||
return requestId
|
||||
}
|
||||
|
||||
logout(){ }
|
||||
logout(){}
|
||||
|
||||
send(roomId, message, option) {
|
||||
const requestId = uuidv4()
|
||||
@@ -95,7 +101,7 @@ class _RocketChatClientService {
|
||||
|
||||
}
|
||||
|
||||
// socket ==================================================================
|
||||
// socket class ==================================================================
|
||||
private socket!: WebSocket;
|
||||
private url = ''
|
||||
private callBacks: {
|
||||
|
||||
Reference in New Issue
Block a user