Skip to content

fix(chat): whisper never delivers a working message to another player - #2426

Open
Khalilx11 wants to merge 1 commit into
NosCoreIO:masterfrom
Khalilx11:fix/whisper-leading-space
Open

Khalilx11 wants to merge 1 commit into
NosCoreIO:masterfrom
Khalilx11:fix/whisper-leading-space

Conversation

@Khalilx11

@Khalilx11 Khalilx11 commented Sep 19, 2026

Copy link
Copy Markdown

Summary

  • WhisperPacketHandler.cs: the raw wire message from the / header carries a leading space before the target name, but the handler split it without trimming - the receiver lookup always saw an empty name (IsNotPlaying on every whisper) and the strip loop left the target name embedded in the delivered text.
  • PubSubHub.cs: SendMessageAsync/SendMessagesAsync broadcast with SignalR's Clients.Others, which excludes the sending WorldServer's own connection - so a whisper between two players on the same WorldServer had zero recipients even with the parsing bug fixed. Changed to Clients.All; verified safe against duplicate delivery since the receiving handler (PostedPacketMessageChannelCommunicationMessageHandler) already filters to a locally-connected session and no-ops otherwise.
  • WorldServerBootstrap.cs: ChannelCommunicationRunner, the hosted service that subscribes to incoming interchannel messages and dispatches them to handlers, was never registered anywhere in the WorldServer host - so nothing was listening for these messages at all, independent of the other two issues.

All three needed to be fixed together for whisper delivery to work end-to-end.

Test plan

  • dotnet build NosCore.sln - 0 warnings, 0 errors
  • Live two-client test: normal map chat received with correct sender
  • Live two-client test: whisper A to B delivered exactly once, correct sender, correctly stripped message
  • Live three-client test: unrelated client does not receive the whisper
  • Sender does not receive a duplicate delivery
  • Invalid/offline whisper target correctly returns IsNotPlaying
  • Multi-WorldServer safety verified by source analysis (receiver-side local-session filter prevents duplicate delivery across instances)

Generated with Claude Code (https://claude.com/claude-code)

Summary by CodeRabbit

  • New Features

    • Messages are now delivered to all connected clients, including the sender.
    • Channel communication now runs automatically as part of the world server.
  • Bug Fixes

    • Whisper messages with leading spaces are now parsed correctly, including messages addressed to a GM.

WhisperPacketHandler split the raw wire message without trimming the
leading space the "/" header leaves before the target name, so the
receiver lookup always failed (IsNotPlaying) and the leaked name stayed
in the delivered text. PubSubHub broadcast with Clients.Others, which
excludes the sender's own WorldServer connection, so same-instance
delivery had no recipient even when the parsing was fixed. WorldServer
never registered ChannelCommunicationRunner as a hosted service, so
nothing was listening for interchannel messages at all - this is why
neither of the above mattered until all three were fixed together.

Verified live with two connected clients plus an unrelated third:
whisper delivers once to the target with the correct sender and
stripped text, the unrelated client receives nothing, the sender gets
no duplicate, and normal map chat is unaffected.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 19, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: NosCoreIO/NosCore/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 8402f54c-b25a-451d-a98c-fb3cbbcf2bf1

📥 Commits

Reviewing files that changed from the base of the PR and between 2baf3da and b4121c8.

📒 Files selected for processing (3)
  • src/NosCore.GameObject/InterChannelCommunication/Hubs/PubSub/PubSubHub.cs
  • src/NosCore.PacketHandlers/Chat/WhisperPacketHandler.cs
  • src/NosCore.WorldServer/WorldServerBootstrap.cs

Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review.


Walkthrough

The PR updates pub/sub broadcasts, trims leading whitespace during whisper parsing, and registers ChannelCommunicationRunner as a hosted service in the world server.

Changes

Communication Updates

Layer / File(s) Summary
Pub/sub broadcast delivery
src/NosCore.GameObject/InterChannelCommunication/Hubs/PubSub/PubSubHub.cs
SendMessageAsync and SendMessagesAsync now send messages through Clients.All.
Whisper message parsing
src/NosCore.PacketHandlers/Chat/WhisperPacketHandler.cs
The handler trims leading spaces before splitting the message and checking the GM prefix.
Channel communication service registration
src/NosCore.WorldServer/WorldServerBootstrap.cs
The world-server host imports the channel communication service namespace and registers ChannelCommunicationRunner as a hosted service.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: erwan-joly

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the primary change: fixing whisper message delivery to another player. It matches the changes across packet handling, hub broadcasting, and hosted-service registration.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

1 participant