follow gateway docs to only return
This commit is contained in:
parent
72ddec2fa0
commit
afddaefe94
1 changed files with 4 additions and 7 deletions
|
@ -11,7 +11,7 @@ import { Message } from "./message.js";
|
||||||
const wsCodesRetry=new Set([4000,4003,4005,4007,4008,4009]);
|
const wsCodesRetry=new Set([4000,4003,4005,4007,4008,4009]);
|
||||||
|
|
||||||
class Localuser{
|
class Localuser{
|
||||||
packets:number;
|
lastSequence:number|null=null;
|
||||||
token:string;
|
token:string;
|
||||||
userinfo:Specialuser;
|
userinfo:Specialuser;
|
||||||
serverurls;
|
serverurls;
|
||||||
|
@ -35,7 +35,6 @@ class Localuser{
|
||||||
connectionSucceed=0;
|
connectionSucceed=0;
|
||||||
errorBackoff=0;
|
errorBackoff=0;
|
||||||
constructor(userinfo:Specialuser){
|
constructor(userinfo:Specialuser){
|
||||||
this.packets=1;
|
|
||||||
this.token=userinfo.token;
|
this.token=userinfo.token;
|
||||||
this.userinfo=userinfo;
|
this.userinfo=userinfo;
|
||||||
this.serverurls=this.userinfo.serverurls;
|
this.serverurls=this.userinfo.serverurls;
|
||||||
|
@ -141,6 +140,8 @@ class Localuser{
|
||||||
|
|
||||||
const temp=JSON.parse(event.data);
|
const temp=JSON.parse(event.data);
|
||||||
console.log(temp)
|
console.log(temp)
|
||||||
|
|
||||||
|
if (temp.s) this.lastSequence=temp.s;
|
||||||
if(temp.op==0){
|
if(temp.op==0){
|
||||||
switch(temp.t){
|
switch(temp.t){
|
||||||
case "MESSAGE_CREATE":
|
case "MESSAGE_CREATE":
|
||||||
|
@ -212,14 +213,10 @@ class Localuser{
|
||||||
this.wsinterval=setInterval(_=>{
|
this.wsinterval=setInterval(_=>{
|
||||||
if (this.connectionSucceed===0) this.connectionSucceed=Date.now()
|
if (this.connectionSucceed===0) this.connectionSucceed=Date.now()
|
||||||
|
|
||||||
this.ws.send(JSON.stringify({op:1,d:this.packets}))
|
this.ws.send(JSON.stringify({op:1,d:this.lastSequence}))
|
||||||
},temp.d.heartbeat_interval)
|
},temp.d.heartbeat_interval)
|
||||||
this.packets=1;
|
|
||||||
}else if(temp.op!=11){
|
|
||||||
this.packets++
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.ws.addEventListener("close", event => {
|
this.ws.addEventListener("close", event => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue