Skip to content
This repository was archived by the owner on Feb 5, 2024. It is now read-only.

Commit f984f56

Browse files
committed
精度を高めるためストリーミング接続中に定期的にlastActiveDateを更新するように
1 parent 2037998 commit f984f56

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/server/api/streaming.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,22 +35,28 @@ module.exports = (server: http.Server) => {
3535

3636
const main = new MainStreamConnection(connection, ev, user, app);
3737

38+
const intervalId = user ? setInterval(() => {
39+
Users.update(user.id, {
40+
lastActiveDate: new Date(),
41+
});
42+
}, 1000 * 60 * 5) : null;
43+
if (user) {
44+
Users.update(user.id, {
45+
lastActiveDate: new Date(),
46+
});
47+
}
48+
3849
connection.once('close', () => {
3950
ev.removeAllListeners();
4051
main.dispose();
4152
redisClient.off('message', onRedisMessage);
53+
if (intervalId) clearInterval(intervalId);
4254
});
4355

4456
connection.on('message', async (data) => {
4557
if (data.utf8Data === 'ping') {
4658
connection.send('pong');
4759
}
4860
});
49-
50-
if (user) {
51-
Users.update(user.id, {
52-
lastActiveDate: new Date(),
53-
});
54-
}
5561
});
5662
};

0 commit comments

Comments
 (0)