|
@@ -7,17 +7,25 @@ const getInKey = (realKey) => {
|
|
|
};
|
|
|
|
|
|
const publishEnterRoom = (userId, roomId) => {
|
|
|
+ const onlineConfigKey = `online:${roomId}:${userId}`;
|
|
|
const payLoad = {
|
|
|
userId,
|
|
|
roomId,
|
|
|
+ type: 0,
|
|
|
+ createTime: Date.now(),
|
|
|
};
|
|
|
+ pubClient.hSet(getInKey(onlineConfigKey), `${payLoad.createTime}`, JSON.stringify(payLoad));
|
|
|
pubClient.publish("enterRoom", JSON.stringify(payLoad));
|
|
|
};
|
|
|
const publishExitRoom = (userId, roomId) => {
|
|
|
+ const onlineConfigKey = `online:${roomId}:${userId}`;
|
|
|
const payLoad = {
|
|
|
userId,
|
|
|
roomId,
|
|
|
+ type: 0,
|
|
|
+ createTime: Date.now(),
|
|
|
};
|
|
|
+ pubClient.hSet(getInKey(onlineConfigKey), `${payLoad.createTime}`, JSON.stringify(payLoad));
|
|
|
pubClient.publish("exitRoom", JSON.stringify(payLoad));
|
|
|
};
|
|
|
|