Skip to content

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

@antosubash

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.

public interface IBroadcaster
{
    Task ToChannelAsync(string channel, string @event, object payload, CancellationToken ct);
    Task ToUserAsync(string userId, string @event, object payload, CancellationToken ct);
    Task ToTenantAsync(string tenantId, string @event, object payload, CancellationToken ct);
}

[BroadcastEvent("orders.created")]
public sealed record OrderCreatedEvent(Guid OrderId, Guid TenantId) : IBroadcastEvent
{
    public string Channel(IBroadcastContext ctx) => $"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