Skip to content
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

[IDLE-466] 웹소켓 연결 및 해제, 데이터 파이프 라인 연결, 에러가 났을 경우 Crashlytics로 로깅하도록 구현 #146

Merged
merged 4 commits into from
Nov 2, 2024

Conversation

tgyuuAn
Copy link
Member

@tgyuuAn tgyuuAn commented Nov 2, 2024

1. 🔥 변경된 내용

  • 웹소켓 연결 및 해제
  • 웹소켓 채팅 데이터 파이프라인 연결
  • 에러가 났을 경우 Firebase Crashlytics로 에러를 로깅하도록 구현
image

PR을 쨋어야했는데.... 하다보니.... ㅠㅠ

2. 📌 고민했던 부분

요구사항 정리

  • 새로운 채팅 메시지 수신: roomId를 확인하여 채팅방 목록에 해당 roomId가 있는지 찾는다.
  • 기존 채팅방이 있을 경우: 해당 채팅방을 목록에서 최상단으로 올리고, 채팅방 정보를 업데이트한다.
  • 새로운 채팅방일 경우: 새로운 채팅방을 생성하여 목록의 최상단에 추가한다.



고려했던 자료구조

  • List, LinkedHashMap



1. List

  • 구조: 단순한 순차 배열로, 각 채팅방을 List의 요소로 관리
  • 장점: 배열 형태로 접근이 간단하며, List 자체가 MutableStateFlow와 잘 어울림
  • 단점: 특정 roomId를 찾을 때 O(n)의 시간 복잡도가 발생합니다. 채팅방을 최상단으로 옮기려면, 요소를 삭제하고 다시 삽입해야 하므로 비효율적일 수 있음.

2. LinkedHashMap

  • 구조: roomId를 키로 하고, 채팅방 데이터를 값으로 가지는 LinkedHashMap을 사용.
  • 장점: 키를 통해 O(1) 시간 복잡도로 특정 채팅방을 찾을 수 있음. 새로운 채팅방을 추가하거나 기존 채팅방을 최상단으로 이동할 때도 remove 후 put하면 효율적으로 순서를 조정할 수 있음.
  • 단점: LinkedHashMap은 순서가 있지만, 이를 MutableStateFlow로 사용하려면 List로 변환해야 함.



결론 : O(1)로 특정 채팅방을 찾을 수 있고, LinkedList의 특성상 remove와 put의 시간복잡도는 O(1) 이기 때문에 매우 적합할 것이라고 판단.

@tgyuuAn tgyuuAn added the 기능 ⚒️ 새로운 기능 구현 ⚒️ label Nov 2, 2024
@tgyuuAn tgyuuAn self-assigned this Nov 2, 2024
@tgyuuAn tgyuuAn added the 새롭게 알게 됨 📖 나 tgyuu가 새롭게 알게된 부분 📖 label Nov 2, 2024
@tgyuuAn tgyuuAn merged commit c37d25c into develop Nov 2, 2024
1 check passed
@tgyuuAn tgyuuAn deleted the feature/IDLE-466 branch November 2, 2024 07:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
기능 ⚒️ 새로운 기능 구현 ⚒️ 새롭게 알게 됨 📖 나 tgyuu가 새롭게 알게된 부분 📖
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant