|
@@ -30,28 +30,22 @@ class LiveroomService extends CrudService {
|
|
|
async personcount(data) {
|
|
|
const { number, name, userid, type } = data;
|
|
|
// 取出已经进入直播的用户列表
|
|
|
- await this.app.redis.del(`liveroom${number}`);
|
|
|
+ // await this.app.redis.del(`liveroom${number}`);
|
|
|
let list = await this.app.redis.get(`liveroom${number}`);
|
|
|
- console.group('group');
|
|
|
- console.table(list);
|
|
|
- console.groupEnd();
|
|
|
if (list) {
|
|
|
- // // 已经开始直播,并且有人观看
|
|
|
+ // 已经开始直播,并且有人观看
|
|
|
list = JSON.parse(list);
|
|
|
} else {
|
|
|
// 还没有人进直播
|
|
|
- list = [{ name, userid }];
|
|
|
+ list = [];
|
|
|
}
|
|
|
if (!type) {
|
|
|
list.push({ name, userid, number });
|
|
|
- list = _.uniqBy(list, 'userid');
|
|
|
} else {
|
|
|
list = list.filter(f => f.userid !== userid);
|
|
|
}
|
|
|
- console.group('group2');
|
|
|
- console.log(JSON.parse(list));
|
|
|
- console.groupEnd();
|
|
|
- await this.app.redis.set(`liveroom${number}`, JSON.parse(list));
|
|
|
+ list = _.uniqBy(list, 'userid');
|
|
|
+ await this.app.redis.set(`liveroom${number}`, JSON.stringify(list));
|
|
|
const { mq } = this.ctx;
|
|
|
if (mq) {
|
|
|
const exchange = 'liveroom-personcount';
|