Skip to content

feat/enhance signal r #75

Merged
Rashed99Azm merged 1 commit into
develop-backendfrom
fix/community-counters-enhance-signal-r
Jun 23, 2026
Merged

feat/enhance signal r #75
Rashed99Azm merged 1 commit into
develop-backendfrom
fix/community-counters-enhance-signal-r

Conversation

@Rashed99Azm

Copy link
Copy Markdown
Collaborator

SignalR Contract Improvements

Summary

This PR improves the realtime SignalR contract by reducing unnecessary client refetches and lowering traffic generated by ephemeral events. The goal is to make common UI updates render directly from SignalR payloads while keeping the implementation lightweight and avoiding the complexity of event replay infrastructure.

Changes

1. Enrich NewReply Payload

NewReply previously contained only identifiers:

{
  "postId": "...",
  "replyId": "...",
  "parentReplyId": "...",
  "depth": 1
}

The event now includes the minimum data required for immediate rendering:

{
  "postId": "...",
  "replyId": "...",
  "parentReplyId": "...",
  "depth": 1,
  "authorId": "...",
  "body": "...",
  "createdOn": "..."
}

Benefit: Clients can insert newly created replies without issuing an additional GET request.


2. Enrich PollResultsChanged Payload

PollResultsChanged previously sent only poll and post identifiers, requiring clients to refetch poll results after every vote.

The event now includes aggregated poll state:

{
  "pollId": "...",
  "postId": "...",
  "totalVotes": 123,
  "options": [
    {
      "id": "...",
      "count": 45
    },
    {
      "id": "...",
      "count": 78
    }
  ]
}

Benefit: Clients can update poll results immediately without additional API calls.


3. Debounce TypingChanged Broadcasts

Typing notifications were previously broadcast on every typing action, producing unnecessary traffic in active discussions.

Typing broadcasts are now throttled/debounced per user and post, reducing duplicate events while preserving realtime UX.

Benefit: Lower SignalR traffic and reduced client update churn in busy threads.


4. Reconnect Recovery Strategy Documentation

Instead of introducing event envelopes, replay infrastructure, or /sync endpoints, this PR formalizes the recommended reconnect behavior:

  1. SignalR reconnects.
  2. Client detects reconnection.
  3. Client refetches the currently visible feed, thread, or resource.

Benefit: Maintains correctness after transient disconnects without introducing event stores, replay mechanisms, sequence tracking, or synchronization endpoints.

Impact

  • Fewer HTTP requests during active discussions.
  • Faster UI updates for replies and poll voting.
  • Reduced websocket traffic from typing indicators.
  • Simpler and well-defined reconnect behavior.
  • No breaking API changes to existing endpoints.

Future Considerations

Potential future enhancements include event envelopes (eventId, occurredOn, version) and replay/synchronization endpoints if stronger delivery guarantees become necessary.

@Rashed99Azm Rashed99Azm merged commit ceb38cb into develop-backend Jun 23, 2026
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.

2 participants