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

Refactor: Migrate Chatroom to Socket Service Architecture #453

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mikaeloduh
Copy link

@mikaeloduh mikaeloduh commented Mar 3, 2025

Why need this change?:

This PR refactors the chatroom-related components to adopt the new SocketService architecture, improving modularity and maintainability.

Changes made:

  • ChatroomProvider: Replaced useChatroomCore with useChatroomService.
  • SocketProvider:
    • Now initializes and manages socket connections via SocketService.
    • Ensured backward compatibility by keeping the raw socket reference.
    • Improved event handling using SocketService methods.
  • SocketContext & Hooks: Updated to support the new service-based approach.

Test Scope / Change impact:

This refactor makes it easier to extend and manage WebSocket connections while reducing direct socket dependencies across the codebase.

Issue

Refactored ChatroomProvider and SocketProvider to use the new SocketService.
Replaced direct socket operations with service-based interactions for better
modularity and maintainability. Updated hooks and context to align with the
new architecture.

- Removed useChatroomCore in favor of useChatroomService
- Updated SocketProvider to manage socket connection via SocketService
- Ensured backward compatibility by keeping raw socket references
Copy link

sonarqubecloud bot commented Mar 3, 2025

@mikaeloduh mikaeloduh linked an issue Mar 3, 2025 that may be closed by this pull request
4 tasks
@GaaSBot
Copy link

GaaSBot commented Mar 3, 2025

Knip Scan Result for 916d804

@GaaSBot
Copy link

GaaSBot commented Mar 3, 2025

🤖 Lighthouse Scan Result for 916d804

/rooms
Metric Value
Performance 75
Seo 90
Accessibility 84
HTML Report for LHCI Scan Report Link
/rooms/abc
Metric Value
Performance 76
Seo 90
Accessibility 84
HTML Report for LHCI Scan Report Link
/login
Metric Value
Performance 69
Seo 90
Accessibility 97
HTML Report for LHCI Scan Report Link

@JohnsonMao
Copy link
Contributor

Looks great! I'll test it out when I have time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

修正 Socket 失效問題並重構專案架構
3 participants