Increment and reset viewer count when appropriate
parent
d79eac6b57
commit
1b551a5b8f
|
@ -27,7 +27,8 @@ async function init() {
|
|||
//If satyr is restarted in the middle of a stream
|
||||
//it causes problems
|
||||
//Live flags in the database stay live
|
||||
await db.query('update user_meta set live=false');
|
||||
await db.query('update user_meta set live=false');
|
||||
await db.query('update user_meta set viewers=0');
|
||||
}
|
||||
|
||||
async function bringUpToDate(): Promise<void>{
|
||||
|
|
|
@ -93,6 +93,8 @@ function init () {
|
|||
db.query('update user_meta,users set user_meta.live=false where users.stream_key='+db.raw.escape(key));
|
||||
db.query('select username from users where stream_key='+db.raw.escape(key)+' limit 1').then(async (results) => {
|
||||
if(results[0]) keystore.rm(results[0].username);
|
||||
// reset viewer count when finished with stream
|
||||
db.query('update user_meta set viewers = 0 where username='+db.raw.escape(results[0].username));
|
||||
});
|
||||
|
||||
}
|
||||
|
@ -119,6 +121,8 @@ function init () {
|
|||
if(app === config['media']['publicEndpoint']) {
|
||||
if(keystore[key]){
|
||||
session.playStreamPath = '/'+config['media']['privateEndpoint']+'/'+keystore[key];
|
||||
// increment viewer count
|
||||
db.query('update user_meta set viewers = viewers + 1 where username='+db.raw.escape(key));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Reference in New Issue