Skip to content
Türkçe

Introducing Magic Socket 1.0.1

Real-time channels, ready in your Magic app.

Real-time broadcasting for Magic apps through the Echo facade, with a Reverb driver and a null driver. Built for a Reverb or other Pusher-protocol server; the API will look familiar to Laravel Echo users.

One facade. Every channel.

Call Echo to listen on public, private and presence channels. The driver you select in broadcasting.default handles the connection.

  • Three channel types

    Echo.channel(name) for public, Echo.private(name) for private (auth through /broadcasting/auth) and Echo.join(name) for presence, with members, onJoin, onLeave.

    Learn more about Three channel types
  • Reconnects on its own

    The Reverb driver reconnects with exponential backoff and jitter and resubscribes every channel after each handshake, so a dropped connection heals without app code.

    Learn more about Reconnects on its own
  • Pick a driver

    broadcasting.default selects reverb for a Reverb or Pusher-protocol server. The default null driver does nothing, so an app without a socket server runs unchanged.

    Learn more about Pick a driver
  • Skip the sender

    While a socket is connected and NetworkServiceProvider is registered, an HTTP interceptor adds X-Socket-ID to each request, so the server's toOthers() skips the sender. Echo.socketId reads it.

    Learn more about Skip the sender
  • Listen in controllers

    The ListensToBroadcasts mixin lets a MagicController listen on a private channel and clean up with the controller (BroadcastListeners.channel).

    Learn more about Listen in controllers
  • Test without a socket

    Echo.fake() swaps in FakeBroadcastManager so a test asserts subscriptions and listeners without a socket, and Echo.unfake() restores it.

    Learn more about Test without a socket

Add it in seconds

~/my_app
flutter pub add magic_socket

Or add to pubspec.yaml:

dependencies:
  magic_socket: ^1.0.1

Or give your AI agent this prompt:

Read https://anilcancakir.com/magic/docs/socket/llms.txt and install the Magic Socket package in this project.