feat: 优化插件加载逻辑

This commit is contained in:
2023-11-09 12:07:41 +08:00
parent 3e8d1f7029
commit 507431232b
19 changed files with 371 additions and 285 deletions

View File

@@ -147,7 +147,7 @@ export class NettyWebSocket extends Transport {
}))
}
abortHandshake(reason: Error): void {
this.handler.abortHandshake(reason)
if (this.handler) this.handler.abortHandshake(reason)
}
getChannel() {
return this.channel

View File

@@ -56,7 +56,8 @@ export abstract class Transport extends EventEmitter {
this.abortHandshake(new Error(msg));
return;
}
if (code != 1000 && (code < 3000 || code > 4999)) {
// if socket is clean ignore code check
if (code != 1000 && (code < 3000 || code > 4999) && !wasClean) {
throw new Error(`The code must be either 1000, or between 3000 and 4999. ${code} is neither.`)
}
this.readyState = WebSocket.CLOSING