-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Socket: ✨ Managing user session status on a socket server #176
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
psychology50
changed the title
Socket: ✨ Managing user session states on a socket server
Socket: ✨ Managing user session status on a socket server
Oct 17, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
작업 이유
작업 사항
1️⃣ User Status
2️⃣ 사용자 세션
deviceId
,deviceName
: 나중에 사용자 기기 FCM 토큰 식별을 위해 필요한 값.status
: 사용자의 현재 상태currentChatRoomId
: 사용자가 채팅방 뷰를 보고 있을 때, 해당 채팅방 아이디lastActiveAt
: 사용자의 메시지(박동 검사 포함)를 수신할 때마다 업데이트되는 값.사실
deviceId
는 필요없을 수 있습니다.어차피 socket-relay에서 채팅방에 가입한
user_id
리스트를 통해, 각 유저의deviceId
를 불러올테니까요.그런데 UserSession에 사용자 식별 가능한 값이 하나도 없어, 일단 불안하여 추가했습니다.
3️⃣ 사용자 상태 활성화
ACTIVE_APP
으로 전환합니다.4️⃣ 사용자 뷰 상태 추적
status.me
path로 전송하여, 상태를 변경합니다.5️⃣ 사용자 상태 비활성화
INACTIVE
로 전환합니다.6️⃣ 사용자 활동 시간 업데이트
필요가 없다고 판단하여, 박동 검사에 대해 사용자 활성 시간을 갱신하는 로직은 추가하지 않았습니다.
이유는 제 블로그에서 발췌한 고찰로 퉁치겠습니다.
리뷰어가 중점적으로 확인해야 하는 부분
발견한 이슈
HEXPIRE
명령어가 있어야만 필드 별로 ttl을 걸 수 있습니다.HEXPIRE
명령어를 사용할 수 있는 메서드를 제공해주지 않아, 네이티브로 처리하려고 했으나 이상한 에러가 발생합니다. 그래서 일단 Lua Script를 이용해서 처리했습니다.