fix reconnection bugs
This commit is contained in:
parent
03d1bc13c7
commit
1d4c771246
6 changed files with 17 additions and 1 deletions
|
@ -100,6 +100,8 @@ class Localuser {
|
||||||
this.guilds = [];
|
this.guilds = [];
|
||||||
this.guildids = new Map();
|
this.guildids = new Map();
|
||||||
this.ws.close(4001);
|
this.ws.close(4001);
|
||||||
|
SnowFlake.clear();
|
||||||
|
User.clear();
|
||||||
}
|
}
|
||||||
async initwebsocket() {
|
async initwebsocket() {
|
||||||
let returny = null;
|
let returny = null;
|
||||||
|
|
|
@ -28,6 +28,9 @@ class SnowFlake {
|
||||||
SnowFlake.FinalizationRegistry.register(this, [id, obj.constructor]);
|
SnowFlake.FinalizationRegistry.register(this, [id, obj.constructor]);
|
||||||
this.obj = obj;
|
this.obj = obj;
|
||||||
}
|
}
|
||||||
|
static clear() {
|
||||||
|
this.SnowFlakes = new Map();
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Just to clarify bc TS, it returns a SnowFlake\<type> which is what you entered with the type parameter
|
* Just to clarify bc TS, it returns a SnowFlake\<type> which is what you entered with the type parameter
|
||||||
*
|
*
|
||||||
|
|
|
@ -54,6 +54,9 @@ class User {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
static clear() {
|
||||||
|
this.userids = {};
|
||||||
|
}
|
||||||
static checkuser(user, owner) {
|
static checkuser(user, owner) {
|
||||||
if (User.userids[user.id]) {
|
if (User.userids[user.id]) {
|
||||||
return User.userids[user.id];
|
return User.userids[user.id];
|
||||||
|
|
|
@ -106,6 +106,8 @@ class Localuser{
|
||||||
this.guilds=[];
|
this.guilds=[];
|
||||||
this.guildids=new Map();
|
this.guildids=new Map();
|
||||||
this.ws.close(4001)
|
this.ws.close(4001)
|
||||||
|
SnowFlake.clear();
|
||||||
|
User.clear();
|
||||||
}
|
}
|
||||||
async initwebsocket():Promise<void>{
|
async initwebsocket():Promise<void>{
|
||||||
let returny=null
|
let returny=null
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
class SnowFlake<x extends WeakKey>{
|
class SnowFlake<x extends WeakKey>{
|
||||||
public readonly id:string;
|
public readonly id:string;
|
||||||
private static readonly SnowFlakes:Map<any,Map<string,WeakRef<SnowFlake<any>>>>=new Map();
|
private static SnowFlakes:Map<any,Map<string,WeakRef<SnowFlake<any>>>>=new Map();
|
||||||
private static readonly FinalizationRegistry=new FinalizationRegistry((a:[string,WeakKey])=>{
|
private static readonly FinalizationRegistry=new FinalizationRegistry((a:[string,WeakKey])=>{
|
||||||
SnowFlake.SnowFlakes.get(a[1]).delete(a[0]);
|
SnowFlake.SnowFlakes.get(a[1]).delete(a[0]);
|
||||||
});
|
});
|
||||||
|
@ -27,6 +27,9 @@ class SnowFlake<x extends WeakKey>{
|
||||||
SnowFlake.FinalizationRegistry.register(this,[id,obj.constructor]);
|
SnowFlake.FinalizationRegistry.register(this,[id,obj.constructor]);
|
||||||
this.obj=obj;
|
this.obj=obj;
|
||||||
}
|
}
|
||||||
|
static clear(){//this is kinda a temp solution, it should be fixed, though its not that easy to do so
|
||||||
|
this.SnowFlakes=new Map();
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Just to clarify bc TS, it returns a SnowFlake\<type> which is what you entered with the type parameter
|
* Just to clarify bc TS, it returns a SnowFlake\<type> which is what you entered with the type parameter
|
||||||
*
|
*
|
||||||
|
|
|
@ -59,6 +59,9 @@ class User{
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
static clear(){
|
||||||
|
this.userids={};
|
||||||
|
}
|
||||||
static checkuser(user:User|userjson,owner:Localuser):User{
|
static checkuser(user:User|userjson,owner:Localuser):User{
|
||||||
if(User.userids[user.id]){
|
if(User.userids[user.id]){
|
||||||
return User.userids[user.id];
|
return User.userids[user.id];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue