mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-16 13:01:14 +00:00
chore: token
This commit is contained in:
parent
b5d24d751d
commit
89188958ec
@ -5,8 +5,10 @@ import { OB11BaseEvent } from '@/onebot/event/OB11BaseEvent';
|
||||
export class OB11ActiveHttpAdapter implements IOB11NetworkAdapter {
|
||||
url: string;
|
||||
private actionMap: Map<string, BaseAction<any, any>> = new Map();
|
||||
heartbeatInterval: number;
|
||||
|
||||
constructor(url: string) {
|
||||
constructor(url: string, heartbeatInterval: number) {
|
||||
this.heartbeatInterval = heartbeatInterval;
|
||||
this.url = url;
|
||||
}
|
||||
registerHeartBeat() {
|
||||
|
@ -12,16 +12,18 @@ export class OB11ActiveWebSocketAdapter implements IOB11NetworkAdapter {
|
||||
|
||||
private connection: NodeWebSocket | null = null;
|
||||
private actionMap: Map<string, BaseAction<any, any>> = new Map();
|
||||
heartbeatInterval: number;
|
||||
|
||||
constructor(url: string, reconnectIntervalInMillis: number) {
|
||||
constructor(url: string, reconnectIntervalInMillis: number, heartbeatInterval: number) {
|
||||
this.url = url;
|
||||
this.heartbeatInterval = heartbeatInterval;
|
||||
this.reconnectIntervalInMillis = reconnectIntervalInMillis;
|
||||
}
|
||||
|
||||
registerHeartBeat() {
|
||||
//WS反向心跳
|
||||
}
|
||||
|
||||
|
||||
registerAction<T extends BaseAction<P, R>, P, R>(action: T) {
|
||||
this.actionMap.set(action.actionName, action);
|
||||
}
|
||||
|
@ -13,12 +13,7 @@ export class OB11NetworkManager {
|
||||
registerAdapter(adapter: IOB11NetworkAdapter) {
|
||||
this.adapters.push(adapter);
|
||||
}
|
||||
|
||||
async open() {
|
||||
await Promise.all(this.adapters.map(adapter => adapter.open()));
|
||||
}
|
||||
|
||||
async close() {
|
||||
async closeAll() {
|
||||
await Promise.all(this.adapters.map(adapter => adapter.close()));
|
||||
}
|
||||
}
|
||||
|
@ -11,9 +11,11 @@ export class OB11PassiveHttpAdapter implements IOB11NetworkAdapter {
|
||||
private hasBeenClosed: boolean = false;
|
||||
private actionMap: Map<string, BaseAction<any, any>> = new Map();
|
||||
private port: number;
|
||||
token: string;
|
||||
|
||||
constructor(port: number) {
|
||||
constructor(port: number,token: string) {
|
||||
this.port = port;
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
registerAction<T extends BaseAction<P, R>, P, R>(action: T) {
|
||||
|
@ -10,10 +10,11 @@ export class OB11PassiveWebSocketAdapter implements IOB11NetworkAdapter {
|
||||
wsClientsMutex = new Mutex();
|
||||
isOpen: boolean = false;
|
||||
hasBeenClosed: boolean = false;
|
||||
|
||||
heartbeatInterval:number = 0;
|
||||
private actionMap: Map<string, BaseAction<any, any>> = new Map();
|
||||
|
||||
constructor(ip: string, port: number, token: string) {
|
||||
constructor(ip: string, port: number, heartbeatInterval: number, token: string) {
|
||||
this.heartbeatInterval = heartbeatInterval;
|
||||
this.wsServer = new WebSocketServer({ port: port, host: ip });
|
||||
this.wsServer.on('connection', async (wsClient) => {
|
||||
if (!this.isOpen) {
|
||||
|
Loading…
Reference in New Issue
Block a user