summaryrefslogtreecommitdiff
path: root/src/server/api
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2021-04-18 22:35:47 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2021-04-18 22:35:47 +0900
commitf984f56459182375421c4af0a31393a8f411a296 (patch)
tree51a016990780445cf656b5baacbffe1dbcc7e7f6 /src/server/api
parentUpdate yarn.lock (diff)
downloadsharkey-f984f56459182375421c4af0a31393a8f411a296.tar.gz
sharkey-f984f56459182375421c4af0a31393a8f411a296.tar.bz2
sharkey-f984f56459182375421c4af0a31393a8f411a296.zip
精度を高めるためストリーミング接続中に定期的にlastActiveDateを更新するように
Diffstat (limited to 'src/server/api')
-rw-r--r--src/server/api/streaming.ts18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/server/api/streaming.ts b/src/server/api/streaming.ts
index 7224c23570..57e8c90860 100644
--- a/src/server/api/streaming.ts
+++ b/src/server/api/streaming.ts
@@ -35,10 +35,22 @@ module.exports = (server: http.Server) => {
const main = new MainStreamConnection(connection, ev, user, app);
+ const intervalId = user ? setInterval(() => {
+ Users.update(user.id, {
+ lastActiveDate: new Date(),
+ });
+ }, 1000 * 60 * 5) : null;
+ if (user) {
+ Users.update(user.id, {
+ lastActiveDate: new Date(),
+ });
+ }
+
connection.once('close', () => {
ev.removeAllListeners();
main.dispose();
redisClient.off('message', onRedisMessage);
+ if (intervalId) clearInterval(intervalId);
});
connection.on('message', async (data) => {
@@ -46,11 +58,5 @@ module.exports = (server: http.Server) => {
connection.send('pong');
}
});
-
- if (user) {
- Users.update(user.id, {
- lastActiveDate: new Date(),
- });
- }
});
};