feat(broadcasting): Echo facade, BroadcastManager, Reverb driver (#37)#38
Merged
anilcancakir merged 4 commits intomasterfrom Apr 5, 2026
Merged
feat(broadcasting): Echo facade, BroadcastManager, Reverb driver (#37)#38anilcancakir merged 4 commits intomasterfrom
anilcancakir merged 4 commits intomasterfrom
Conversation
… full testing support (#37) Laravel Echo equivalent for real-time WebSocket channels. Pusher-compatible ReverbBroadcastDriver with automatic reconnection (exponential backoff), event deduplication (ring buffer), application-level heartbeat, and interceptor pipeline. NullBroadcastDriver for local dev. Echo.fake() for testing with assertion helpers. BroadcastServiceProvider (opt-in). CLI install stubs with --without-broadcasting flag.
There was a problem hiding this comment.
Pull request overview
Adds a first-class broadcasting/WebSocket subsystem to Magic (Laravel Echo–style) including a new Echo facade, a config-driven BroadcastManager, and a Pusher/Reverb-compatible WebSocket driver, along with testing fakes and documentation updates.
Changes:
- Introduces the broadcasting public API (
Echofacade + contracts) and container integration (BroadcastManager,BroadcastServiceProvider, default config export). - Implements built-in drivers:
ReverbBroadcastDriver(Pusher protocol) andNullBroadcastDriver(no-op). - Adds extensive test coverage plus docs/README/skill references and CLI documentation updates.
Reviewed changes
Copilot reviewed 32 out of 33 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
| test/testing/fake_broadcast_manager_test.dart | Tests FakeBroadcastManager behavior and Echo fake integration. |
| test/broadcasting/echo_facade_test.dart | Verifies Echo facade API routes through manager/driver correctly. |
| test/broadcasting/drivers/reverb_broadcast_driver_test.dart | Unit tests for Reverb driver lifecycle, protocol handling, reconnection, dedup, interceptors, channels. |
| test/broadcasting/drivers/null_broadcast_driver_test.dart | Tests NullBroadcastDriver no-op semantics and silent channels. |
| test/broadcasting/broadcast_service_provider_test.dart | Verifies provider registration and boot behavior with null default. |
| test/broadcasting/broadcast_manager_test.dart | Tests driver resolution, caching, and custom driver registry behavior. |
| test/broadcasting/broadcast_event_test.dart | Tests BroadcastEvent and BroadcastConnectionState basics. |
| skills/magic-framework/SKILL.md | Updates facade count and adds Echo to framework skill reference. |
| skills/magic-framework/references/secondary-systems.md | Adds broadcasting docs to the “secondary systems” reference. |
| skills/magic-framework/references/cli-commands.md | Documents new CLI install flag and generated broadcasting config. |
| README.md | Adds broadcasting feature highlight and includes Echo.fake() in testing list. |
| pubspec.yaml | Adds web_socket_channel dependency for WebSocket support. |
| lib/src/testing/fake_broadcast_manager.dart | Implements FakeBroadcastManager + FakeBroadcastDriver for tests/assertions. |
| lib/src/foundation/application.dart | Registers default broadcasting config into the app’s default config set. |
| lib/src/facades/echo.dart | Adds Echo facade API (channels, lifecycle, interceptors, fake/unfake). |
| lib/src/broadcasting/drivers/reverb_broadcast_driver.dart | Implements Pusher-compatible WebSocket driver + channels + presence. |
| lib/src/broadcasting/drivers/null_broadcast_driver.dart | Implements no-op broadcast driver and silent channels. |
| lib/src/broadcasting/contracts/broadcast_presence_channel.dart | Defines presence channel contract (members/onJoin/onLeave). |
| lib/src/broadcasting/contracts/broadcast_interceptor.dart | Defines interceptor hooks with pass-through defaults. |
| lib/src/broadcasting/contracts/broadcast_driver.dart | Defines broadcast driver interface for connections/channels. |
| lib/src/broadcasting/contracts/broadcast_channel.dart | Defines broadcast channel interface for events + named listeners. |
| lib/src/broadcasting/broadcast_service_provider.dart | Adds service provider to bind manager and optionally auto-connect. |
| lib/src/broadcasting/broadcast_manager.dart | Adds config-driven driver resolution with extend() registry + caching. |
| lib/src/broadcasting/broadcast_event.dart | Adds immutable BroadcastEvent envelope. |
| lib/src/broadcasting/broadcast_connection_state.dart | Adds connection state enum. |
| lib/magic.dart | Exports broadcasting API + config + testing fake. |
| lib/config/broadcasting.dart | Provides default broadcasting configuration map. |
| example/pubspec.lock | Updates example lockfile for new dependency resolution. |
| doc/packages/magic-cli.md | Documents --without-broadcasting in CLI package docs. |
| doc/getting-started/installation.md | Updates installation docs to mention broadcasting config + flag. |
| doc/digging-deeper/broadcasting.md | Adds full broadcasting guide (config, usage, drivers, testing). |
| CHANGELOG.md | Adds unreleased changelog entry for broadcasting feature set. |
| .claude/rules/broadcasting.md | Adds internal domain rules/reference for broadcasting subsystem. |
…ars, resource leak - Fix docstring examples: Broadcast.xxx → Echo.xxx in all contracts - Fix NullBroadcastDriver docstring config namespace (broadcast → broadcasting) - Fix BroadcastServiceProvider docstring facade reference (Broadcast → Echo) - Fix _authenticateAndSubscribe: safe type check instead of direct cast - Fix reconnect resource leak: close existing WebSocket before reconnecting - Fix env var consistency: BROADCAST_DRIVER → BROADCAST_CONNECTION everywhere - Remove no-op mock.sentFrames in ping/pong test
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
…, presence, interceptor defaults Adds 29 tests covering previously uncovered paths: - _onDone/_onError reconnection and interceptor routing - _handlePusherError with fatal/immediate/backoff/malformed codes - Presence events routed through driver (member_added/removed, subscription_succeeded) - Subscription queue for private/presence channels before connect - BroadcastInterceptor base class pass-through defaults (onSend/onReceive/onError) - Echo.listen() and Echo.leave() facade methods - BroadcastManager reverb driver resolution - BroadcastServiceProvider boot with non-null driver - Application event edge cases (unknown channel, missing channel, non-Map data)
Published version includes broadcasting config stub, env var fixes, and install command --without-broadcasting support.
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
channel(),private(),join(),listen(),leave(),connect(),disconnect(),socketId,connectionState,onReconnect,addInterceptor(),fake()/unfake()channelFactoryDI for testabilityconst Stream.empty()for local devextend()for custom drivers, follows LogManager/CacheManager patternonSend(Map),onReceive(BroadcastEvent),onError(dynamic)with pass-through defaults'null'Echo.fake()returns fake with assertion helpers:assertConnected(),assertDisconnected(),assertSubscribed(),assertNotSubscribed(),assertInterceptorAdded()--without-broadcastingflag,broadcasting_config.stub, env vars (BROADCAST_DRIVER, REVERB_HOST/PORT/SCHEME/APP_KEY)doc/digging-deeper/broadcasting.md(9 sections),.claude/rules/broadcasting.md, skill references, CLI docs updatedTest plan
flutter test) — 123 new broadcasting tests across 7 test filesdart analyze— zero warnings, zero errorsCloses #37