Skip to content

feat(broadcasting): SignalR hub + @simplemodule/echo client (closes #169)#193

Merged
antosubash merged 1 commit into
mainfrom
feature/feat-broadcasting-signalr-simplemodule-echo-client-u3s0f
May 11, 2026
Merged

feat(broadcasting): SignalR hub + @simplemodule/echo client (closes #169)#193
antosubash merged 1 commit into
mainfrom
feature/feat-broadcasting-signalr-simplemodule-echo-client-u3s0f

Conversation

@antosubash
Copy link
Copy Markdown
Owner

Summary

Adds real-time push from server to browser. Modules either implement IBroadcastEvent on a domain event or call IBroadcaster directly; a Scrutor decorator over Wolverine's IMessageBus forwards every IBroadcastEvent publish to SignalR clients connected to BroadcastHub at /hub/broadcast.

  • Framework abstractions (SimpleModule.Core/Broadcasting/): IBroadcaster, IBroadcastEvent, [BroadcastEvent], IBroadcastChannelAuthorizer, IBroadcastContext, BroadcastChannels, wire envelopes.
  • Hosting (SimpleModule.Hosting/Broadcasting/): BroadcastHub with Subscribe/Unsubscribe + presence join/leave, SignalR-backed Broadcaster, PresenceTracker, BroadcastAuthorizerChain (longest-prefix wins) with default user / tenant guards, and BroadcastingMessageBus decorator.
  • Client (@simplemodule/echo): SignalR-backed Echo class with EchoProvider, useEvent, usePresence; ref-counted subscriptions, auto-reconnect with re-subscribe + presence snapshot re-dispatch, in-flight subscribe deduplication.
  • Demo: /broadcasting page in the Dashboard module — connection status badge, live tick counter, and a fire button hitting an authenticated IBroadcaster.ToUserAsync route.
  • Docs: docs/broadcasting.md.

Verification

  • Manually exercised the demo at https://localhost:5001/broadcasting via playwright-cli — connection state went to connected, three "Fire tick" clicks incremented the in-page counter 0→1→2→3 with timestamps, no broadcasting-related console errors.
  • 22 broadcasting unit + integration tests pass (attribute discovery, presence-tracker concurrency, authorizer chain, end-to-end bus-decorator forwarding through real Wolverine).
  • All local CI steps green: npm run check, npm run build, dotnet build, dotnet test (1010/1010 across 17 projects), npm run test:smoke -w tests/e2e (47/47).

Test plan

  • CI green on PR
  • Reviewer spot-checks the BroadcastingMessageBus decorator and the BroadcastAuthorizerChain longest-prefix matching
  • Reviewer verifies the Echo client's reconnect + re-subscribe behaviour by stopping/starting the host with the demo page open

)

Adds real-time push from server to browser. Modules raise events that
implement IBroadcastEvent (or call IBroadcaster directly); a Scrutor
decorator over Wolverine's IMessageBus mirrors those events to clients
through the BroadcastHub at /hub/broadcast.

- Framework abstractions in SimpleModule.Core/Broadcasting: IBroadcaster,
  IBroadcastEvent, [BroadcastEvent], IBroadcastChannelAuthorizer,
  IBroadcastContext, BroadcastChannels, wire envelopes.
- SimpleModule.Hosting: BroadcastHub, SignalR-backed Broadcaster,
  PresenceTracker, BroadcastAuthorizerChain with default user/tenant
  guards, BroadcastingMessageBus decorator.
- @simplemodule/echo: SignalR-backed client with EchoProvider, useEvent,
  usePresence; ref-counted subscriptions, auto-reconnect, presence snapshots.
- Demo: /broadcasting page in the Dashboard module with live tick counter
  and a fire button hitting an authenticated IBroadcaster route.
- Tests: 22 unit + integration tests covering attribute discovery,
  presence tracking concurrency, authorizer chain, and the bus-decorator
  forwarding path.
@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying simplemodule-website with  Cloudflare Pages  Cloudflare Pages

Latest commit: c0200a7
Status: ✅  Deploy successful!
Preview URL: https://4d5f96fb.simplemodule-website.pages.dev
Branch Preview URL: https://feature-feat-broadcasting-si.simplemodule-website.pages.dev

View logs

@antosubash antosubash merged commit d139118 into main May 11, 2026
6 checks passed
@antosubash antosubash deleted the feature/feat-broadcasting-signalr-simplemodule-echo-client-u3s0f branch May 11, 2026 18:57
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