diff options
author | Chocobozzz <me@florianbigard.com> | 2021-11-09 10:11:20 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2021-11-09 15:00:31 +0100 |
commit | 51353d9a035fb6b81f903a8b5f391292841649fd (patch) | |
tree | 75acb6eea5e043bf2e15a6a5a92e9a3c5967b156 /server/lib/peertube-socket.ts | |
parent | 221ee1adc916684d4881d2a9c4c01954dcde986e (diff) | |
download | PeerTube-51353d9a035fb6b81f903a8b5f391292841649fd.tar.gz PeerTube-51353d9a035fb6b81f903a8b5f391292841649fd.tar.zst PeerTube-51353d9a035fb6b81f903a8b5f391292841649fd.zip |
Refactor video views
Introduce viewers attribute for live videos
Count views for live videos
Reduce delay to see the viewer update for lives
Add ability to configure video views buffer interval and view ip
expiration
Diffstat (limited to 'server/lib/peertube-socket.ts')
-rw-r--r-- | server/lib/peertube-socket.ts | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/server/lib/peertube-socket.ts b/server/lib/peertube-socket.ts index 901435dea..0398ca61d 100644 --- a/server/lib/peertube-socket.ts +++ b/server/lib/peertube-socket.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import { Server as HTTPServer } from 'http' | 1 | import { Server as HTTPServer } from 'http' |
2 | import { Namespace, Server as SocketServer, Socket } from 'socket.io' | 2 | import { Namespace, Server as SocketServer, Socket } from 'socket.io' |
3 | import { isIdValid } from '@server/helpers/custom-validators/misc' | 3 | import { isIdValid } from '@server/helpers/custom-validators/misc' |
4 | import { MVideo } from '@server/types/models' | 4 | import { MVideo, MVideoImmutable } from '@server/types/models' |
5 | import { UserNotificationModelForApi } from '@server/types/models/user' | 5 | import { UserNotificationModelForApi } from '@server/types/models/user' |
6 | import { LiveVideoEventPayload, LiveVideoEventType } from '@shared/models' | 6 | import { LiveVideoEventPayload, LiveVideoEventType } from '@shared/models' |
7 | import { logger } from '../helpers/logger' | 7 | import { logger } from '../helpers/logger' |
@@ -78,11 +78,11 @@ class PeerTubeSocket { | |||
78 | .emit(type, data) | 78 | .emit(type, data) |
79 | } | 79 | } |
80 | 80 | ||
81 | sendVideoViewsUpdate (video: MVideo) { | 81 | sendVideoViewsUpdate (video: MVideoImmutable, numViewers: number) { |
82 | const data: LiveVideoEventPayload = { views: video.views } | 82 | const data: LiveVideoEventPayload = { viewers: numViewers, views: numViewers } |
83 | const type: LiveVideoEventType = 'views-change' | 83 | const type: LiveVideoEventType = 'views-change' |
84 | 84 | ||
85 | logger.debug('Sending video live views update notification of %s.', video.url, { views: video.views }) | 85 | logger.debug('Sending video live views update notification of %s.', video.url, { viewers: numViewers }) |
86 | 86 | ||
87 | this.liveVideosNamespace | 87 | this.liveVideosNamespace |
88 | .in(video.id) | 88 | .in(video.id) |