mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-21 09:36:35 +00:00
fix: ws心跳实现
This commit is contained in:
parent
eab930c083
commit
d76503995c
@ -79,6 +79,12 @@ export class OB11ActiveWebSocketAdapter implements IOB11NetworkAdapter {
|
||||
},
|
||||
|
||||
});
|
||||
this.connection.on('ping', () => {
|
||||
this.connection?.pong();
|
||||
});
|
||||
this.connection.on('pong', () => {
|
||||
//this.logger.logDebug('[OneBot] [WebSocket Client] 收到pong');
|
||||
});
|
||||
this.connection.on('open', () => {
|
||||
try {
|
||||
this.connectEvent(this.coreContext);
|
||||
|
@ -50,6 +50,12 @@ export class OB11PassiveWebSocketAdapter implements IOB11NetworkAdapter {
|
||||
wsClient.on('message', (message) => {
|
||||
this.handleMessage(wsClient, message).then().catch(this.logger.logError);
|
||||
});
|
||||
wsClient.on('ping', () => {
|
||||
wsClient.pong();
|
||||
});
|
||||
wsClient.on('pong', () => {
|
||||
//this.logger.logDebug('[OneBot] [WebSocket Server] Pong received');
|
||||
});
|
||||
wsClient.once('close', () => {
|
||||
this.wsClientsMutex.runExclusive(async () => {
|
||||
const index = this.wsClients.indexOf(wsClient);
|
||||
|
Loading…
x
Reference in New Issue
Block a user