Skip to content

Add Broadcasting (SignalR server + @simplemodule/echo client) #169

Description

@antosubash

Background

There is no way to push real-time events from server to browser. Modules cannot do live notifications, live dashboards, presence, or collaborative UI. Laravel Broadcasting + Echo solves this with private/presence channels and event-driven push (Pusher / Reverb / Soketi).

Motivation

Design sketch

Server: SignalR hub BroadcastHub mounted at /hub/broadcast.

publicinterfaceIBroadcaster{TaskToChannelAsync(stringchannel,string@event,objectpayload,CancellationTokenct);TaskToUserAsync(stringuserId,string@event,objectpayload,CancellationTokenct);TaskToTenantAsync(stringtenantId,string@event,objectpayload,CancellationTokenct);}[BroadcastEvent("orders.created")]publicsealedrecordOrderCreatedEvent(GuidOrderId,GuidTenantId):IBroadcastEvent{publicstringChannel(IBroadcastContextctx)=>$"tenants.{TenantId}.orders";}
  • Bridge from IEventBus: any event marked [BroadcastEvent] is automatically forwarded to subscribers
  • Channel authorization: IBroadcastChannelAuthorizer per channel (hub callback validates ClaimsPrincipal before allowing subscription)
  • Presence channels: server tracks members, broadcasts join/leave
  • Private channels: same as public, but require explicit auth

Client (packages/echo):

import{useChannel}from'@simplemodule/echo';useChannel('tenants.123.orders').on('orders.created',(e)=>{ ... });
  • Built on @microsoft/signalr; auto-reconnect; backoff; auth via current Inertia session cookie

Acceptance criteria

  • IBroadcaster + BroadcastHub in framework
  • [BroadcastEvent] discovered by source generator; bridge from IEventBus
  • Channel authorizer pattern with at least one example
  • Presence channel implementation
  • @simplemodule/echo package with useChannel / useEvent hooks
  • xUnit + integration tests
  • Demo: live notification bell in template app
  • Docs page

References

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions