mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-21 09:36:35 +00:00
feat: implement ActiveHttp.open / close
This commit is contained in:
parent
a955937e02
commit
57821b839e
@ -14,6 +14,7 @@ export class OB11ActiveHttpAdapter implements IOB11NetworkAdapter {
|
|||||||
coreContext: NapCatCore;
|
coreContext: NapCatCore;
|
||||||
obContext: NapCatOneBot11Adapter;
|
obContext: NapCatOneBot11Adapter;
|
||||||
logger: LogWrapper;
|
logger: LogWrapper;
|
||||||
|
isOpen: boolean = false;
|
||||||
|
|
||||||
constructor(url: string, heartbeatInterval: number, secret: string | undefined, coreContext: NapCatCore, onebotContext: NapCatOneBot11Adapter) {
|
constructor(url: string, heartbeatInterval: number, secret: string | undefined, coreContext: NapCatCore, onebotContext: NapCatOneBot11Adapter) {
|
||||||
this.heartbeatInterval = heartbeatInterval;
|
this.heartbeatInterval = heartbeatInterval;
|
||||||
@ -32,6 +33,9 @@ export class OB11ActiveHttpAdapter implements IOB11NetworkAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onEvent<T extends OB11EmitEventContent>(event: T) {
|
onEvent<T extends OB11EmitEventContent>(event: T) {
|
||||||
|
if (!this.isOpen) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const headers: Record<string, string> = {
|
const headers: Record<string, string> = {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'x-self-id': this.coreContext.selfInfo.uin,
|
'x-self-id': this.coreContext.selfInfo.uin,
|
||||||
@ -64,13 +68,11 @@ export class OB11ActiveHttpAdapter implements IOB11NetworkAdapter {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async open() {
|
open() {
|
||||||
// HTTP adapter does not need to establish a persistent connection
|
this.isOpen = true;
|
||||||
//console.log('HTTP adapter is ready to send events.');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
close() {
|
close() {
|
||||||
// HTTP adapter does not need to close a persistent connection
|
this.isOpen = false;
|
||||||
// console.log('HTTP adapter does not maintain a persistent connection.');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user