Skip to content

Centralize message ID constants for protocol discoverability#2801

Merged
drazisil merged 1 commit into
devfrom
feature/centralize-message-ids
Jan 21, 2026
Merged

Centralize message ID constants for protocol discoverability#2801
drazisil merged 1 commit into
devfrom
feature/centralize-message-ids

Conversation

@drazisil

@drazisil drazisil commented Jan 21, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Create packages/shared/src/constants/ with NPS, Auth, and MCOTS message ID constants
  • Update lobby and authentication handler registries to use named constants instead of magic numbers
  • Update handleOpenCommChannel.ts to use constants for response message IDs

Motivation

Message IDs were previously:

  • Hardcoded in handler registries (opCode: 0x100)
  • Hardcoded in message classes (id = 0x614)
  • Scattered across packages with no central reference

This change 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)

Test plan

  • All 433 unit tests pass
  • No hardcoded opCode: 0x values remain in registries
  • Manual verification: Start server and verify handlers register correctly

🤖 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.

  • Adds packages/shared/src/constants/ with NPS_MESSAGE_IDS, AUTH_MESSAGE_IDS, and MCOTS_MESSAGE_IDS, and re-exports via shared/index.ts
  • Updates authentication and lobby handler registries to use NPS_MESSAGE_IDS/AUTH_MESSAGE_IDS instead of hardcoded opCode values
  • Switches handleOpenCommChannel to use NPS_MESSAGE_IDS.USER_JOINED_CHANNEL and NPS_MESSAGE_IDS.CHANNEL_GRANTED for response messages
  • Normalizes npsCommandHandlers to named constants (including UDP_STATUS and GET_MINI_USER_LIST) and consistent trailing commas/ordering

Written by Cursor Bugbot for commit b6ef577. This will update automatically on new commits. Configure here.

- 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>
@sonarqubecloud

Copy link
Copy Markdown

@deepsource-io

deepsource-io Bot commented Jan 21, 2026

Copy link
Copy Markdown

Here's the code health analysis summary for commits 574fe37..b6ef577. View details on DeepSource ↗.

Analysis Summary

AnalyzerStatusSummaryLink
DeepSource JavaScript LogoJavaScript✅ SuccessView Check ↗

💡 If you’re a repository administrator, you can configure the quality gates from the settings.

@codecov

codecov Bot commented Jan 21, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 44.31818% with 49 lines in your changes missing coverage. Please review.
✅ Project coverage is 32.53%. Comparing base (574fe37) to head (b6ef577).
⚠️ Report is 2 commits behind head on dev.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
packages/lobby/src/handlers/npsCommandHandlers.ts 0.00% 33 Missing ⚠️
packages/authentication/src/handlers/registry.ts 0.00% 8 Missing ⚠️
packages/lobby/src/handlers/registry.ts 0.00% 6 Missing ⚠️
...ckages/lobby/src/handlers/handleOpenCommChannel.ts 0.00% 2 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

@drazisil drazisil enabled auto-merge January 21, 2026 04:28
@drazisil drazisil disabled auto-merge January 21, 2026 04:30
@drazisil drazisil added this pull request to the merge queue Jan 21, 2026
Merged via the queue into dev with commit b9aef4f Jan 21, 2026
17 checks passed
@drazisil drazisil deleted the feature/centralize-message-ids branch January 21, 2026 04:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant