Centralize message ID constants for protocol discoverability#2801
Merged
Conversation
- Create packages/shared/src/constants/ with NPS, Auth, and MCOTS message IDs - Export constants from rusty-motors-shared package - Update lobby handler registry to use NPS_MESSAGE_IDS constants - Update npsCommandHandlers.ts to use NPS_MESSAGE_IDS constants - Update authentication handler registry to use AUTH_MESSAGE_IDS constants - Update handleOpenCommChannel.ts to use constants for response IDs This provides: - Single source of truth for all protocol message IDs - Better discoverability of supported messages - Foundation for future conflict detection and typed packets - Improved code readability (named constants vs magic numbers) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
|
Here's the code health analysis summary for commits Analysis Summary
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## dev #2801 +/- ##
==========================================
+ Coverage 32.40% 32.53% +0.12%
==========================================
Files 288 292 +4
Lines 20408 20448 +40
Branches 366 366
==========================================
+ Hits 6613 6652 +39
- Misses 13791 13792 +1
Partials 4 4 ☔ View full report in Codecov by Sentry. |
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.



Summary
packages/shared/src/constants/with NPS, Auth, and MCOTS message ID constantshandleOpenCommChannel.tsto use constants for response message IDsMotivation
Message IDs were previously:
opCode: 0x100)id = 0x614)This change provides:
Test plan
opCode: 0xvalues remain in registries🤖 Generated with Claude Code
Note
Introduces a single source of truth for protocol message IDs and replaces magic numbers across handlers for clarity and consistency.
packages/shared/src/constants/withNPS_MESSAGE_IDS,AUTH_MESSAGE_IDS, andMCOTS_MESSAGE_IDS, and re-exports viashared/index.tsNPS_MESSAGE_IDS/AUTH_MESSAGE_IDSinstead of hardcodedopCodevalueshandleOpenCommChannelto useNPS_MESSAGE_IDS.USER_JOINED_CHANNELandNPS_MESSAGE_IDS.CHANNEL_GRANTEDfor response messagesnpsCommandHandlersto named constants (includingUDP_STATUSandGET_MINI_USER_LIST) and consistent trailing commas/orderingWritten by Cursor Bugbot for commit b6ef577. This will update automatically on new commits. Configure here.