mirror of
https://activitypub.software/TransFem-org/Sharkey
synced 2024-11-25 23:45:13 +00:00
enhance(backend): WebSocketのPing/Pongをプロトコル制御フレームの物で判別する
Resolve #10969
This commit is contained in:
parent
308ab8f177
commit
6182a1cb2c
1 changed files with 5 additions and 6 deletions
|
@ -132,11 +132,8 @@ export class StreamingApiServerService {
|
||||||
if (userUpdateIntervalId) clearInterval(userUpdateIntervalId);
|
if (userUpdateIntervalId) clearInterval(userUpdateIntervalId);
|
||||||
});
|
});
|
||||||
|
|
||||||
connection.on('message', async (data) => {
|
connection.on('pong', () => {
|
||||||
this.#connections.set(connection, Date.now());
|
this.#connections.set(connection, Date.now());
|
||||||
if (data.toString() === 'ping') {
|
|
||||||
connection.send('pong');
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -144,12 +141,14 @@ export class StreamingApiServerService {
|
||||||
this.#cleanConnectionsIntervalId = setInterval(() => {
|
this.#cleanConnectionsIntervalId = setInterval(() => {
|
||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
for (const [connection, lastActive] of this.#connections.entries()) {
|
for (const [connection, lastActive] of this.#connections.entries()) {
|
||||||
if (now - lastActive > 1000 * 60 * 5) {
|
if (now - lastActive > 1000 * 60 * 2) {
|
||||||
connection.terminate();
|
connection.terminate();
|
||||||
this.#connections.delete(connection);
|
this.#connections.delete(connection);
|
||||||
|
} else {
|
||||||
|
connection.ping();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 1000 * 60 * 5);
|
}, 1000 * 60);
|
||||||
}
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
|
|
Loading…
Reference in a new issue