Open
Conversation
1. Removed Duplicate Event Handlers • Originally, you had two separate typing events → one calling a controller, and one broadcasting directly. • Now, we keep only the broadcasting version inside registerChatEvents, avoiding duplication and possible conflicts. 2. Centralized Error Handling • Instead of repeating error checks in every event: • We now have a handleResult() utility that standardizes error logging and socket emission. 3. Grouped Events by Category • Separated events into: • registerFileEvents • registerRoomEvents • registerChatEvents • registerVideoCallEvents • This makes the code easier to navigate and maintain. If you add a new event, you know exactly where it belongs. 4. Consistent Event Naming • Changed event names to use kebab-case (join-room, leave-room, join-call). • This ensures naming consistency across all socket events. 5. Dynamic File Event Mapping • Instead of writing repetitive handlers: • We loop over an array of file events and dynamically call the matching controller method (handleCreateFile, handleDeleteFile, etc.). • This reduces repetition and makes it easier to add/remove file-related events. 6. Better Disconnect Handling • Previously, only the RoomController handled disconnects. • Now, both RoomController and VideoCallController are given a chance to clean up when a user disconnects. 7. Future-Proofing (Async Ready) • Although this refactor keeps methods synchronous, the structure (handleResult) allows easy switch to async/await later if controllers perform DB or API calls. Net result: • Cleaner • DRY (Don’t Repeat Yourself) • Easier to extend • Consistent naming • Robust disconnect handling
This file contains hidden or 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
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.
• Cleaner
• DRY (Don’t Repeat Yourself)
• Easier to extend
• Consistent naming
• Robust disconnect handling