|
@@ -20,7 +20,7 @@ const isHoster = (role) => {
|
|
|
const buildRoom = async (roomId, userId, user) => {
|
|
|
const hasJoin = await pubClient.HVALS(roomId, userId);
|
|
|
if (hasJoin.length === 0) {
|
|
|
- log.info("创建房间", { roomId });
|
|
|
+ logger.info("buildRoom", { roomId });
|
|
|
await pubClient.hSet(roomId, userId, JSON.stringify(user));
|
|
|
}
|
|
|
};
|
|
@@ -31,7 +31,7 @@ const buildRoom = async (roomId, userId, user) => {
|
|
|
*/
|
|
|
|
|
|
const removeRoom = async (roomId) => {
|
|
|
- log.info("removeRoom", { roomId });
|
|
|
+ logger.info("removeRoom", { roomId });
|
|
|
await pubClient.del(roomId);
|
|
|
};
|
|
|
|
|
@@ -42,7 +42,7 @@ const removeRoom = async (roomId) => {
|
|
|
* @param {*} user
|
|
|
*/
|
|
|
const joinRoom = async (roomId, userId, user) => {
|
|
|
- log.info("joinRoom", { roomId });
|
|
|
+ logger.info("joinRoom", { roomId });
|
|
|
const hasRoom = await pubClient.exists(roomId);
|
|
|
if (hasRoom) {
|
|
|
await pubClient.hSet(roomId, userId, JSON.stringify(user));
|
|
@@ -56,7 +56,7 @@ const joinRoom = async (roomId, userId, user) => {
|
|
|
*/
|
|
|
|
|
|
const leaveRoom = async (roomId, userId) => {
|
|
|
- console.log("leaveRoom", roomId);
|
|
|
+ logger.info("leaveRoom", roomId);
|
|
|
await pubClient.hDel(roomId, userId);
|
|
|
};
|
|
|
|
|
@@ -111,7 +111,7 @@ export async function roomController(socket) {
|
|
|
if ("roomId" in user && "userId" in user) {
|
|
|
user.isLogin = true;
|
|
|
await pubClient.hSet(userUniqueId, user);
|
|
|
- await pubClient.expire(userUniqueId, 60 * 60 * 1);
|
|
|
+ await pubClient.expire(userUniqueId, 60 * 60 * 24);
|
|
|
// 房主自动创建房间
|
|
|
|
|
|
if (isHoster(role) && Number(from) === 0) {
|