Fix bugs with updating viewer count
parent
bcba160146
commit
dd940ff46f
|
@ -630,6 +630,7 @@ async function initChat() {
|
|||
let rooms = Object.keys(socket.rooms);
|
||||
for(let i=1;i<rooms.length;i++){
|
||||
io.to(rooms[i]).emit('ALERT', socket.nick+' disconnected');
|
||||
db.query('update user_meta set viewers = viewers - 1 where username='+db.raw.escape(rooms[i]));
|
||||
}
|
||||
if(Array.isArray(store.get(socket.nick))) {
|
||||
store.set(socket.nick, store.get(socket.nick).filter(item => item !== socket.id))
|
||||
|
|
|
@ -129,13 +129,8 @@ function init () {
|
|||
let session = nms.getSession(id);
|
||||
let app: string = StreamPath.split("/")[1];
|
||||
let key: string = StreamPath.split("/")[2];
|
||||
if(!session.isLocal && app === config['media']['publicEndpoint']) {
|
||||
if(keystore[key]){
|
||||
// increment viewer count
|
||||
db.query('update user_meta set viewers = viewers - 1 where username='+db.raw.escape(key));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// decrement viewer count
|
||||
db.query('update user_meta,users set user_meta.viewers = user_meta.viewers - 1 where users.stream_key='+db.raw.escape(key));
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Reference in New Issue