magic_socket 1.0.1
magic_socket: ^1.0.1 copied to clipboard
Real-time broadcasting for Magic apps: the Echo facade, Reverb and null drivers, private and presence channels.
Changelog #
All notable changes to this project will be documented in this file.
1.0.1 - 2026-11-15 #
Changed #
- The package page is
https://anilcancakir.com/magic/socketand the documentation links sit underhttps://anilcancakir.com/magic/docs/socket. - An
AuthChannelSubscriptioncompares the channel it holds with the oneprivate(name)returns by identity, so a customBroadcastDrivermust return the instance it already holds for a registered name; a driver that mints a new channel on every call makes eachsyncregister the channel again and fireonReconnectonce the new channel is confirmed. The custom driver guide lists this obligation.
Fixed #
Echo.leave('chat.1')now leaves the channelEcho.private('chat.1')orEcho.join('chat.1')opened, as Laravel Echo does; it used to keep the server subscription and its listeners alive. It drops all three forms of the name, so it also leaves a publicchat.1. The prefixed name still works, andEcho.fakebehaves the same.- An
AuthChannelSubscription(and soListensToBroadcastsandBroadcastListeners) receives events again after anEcho.disconnect()made elsewhere: its nextsyncregisters the channel again and firesonReconnectonce it is confirmed, or at once when another consumer already had it confirmed again. Echo.fake'sdisconnect,leaveandresetnow forget the handlers and recorded subscriptions of the channels they drop and end those channels'onSubscriptionChangedstreams, as the real driver does. A test that callsassertSubscribed,assertListeningordispatchafterEcho.disconnect()orEcho.leave(x)now fails, and a subscription registers its channel again after a disconnect, so it appears insubscribedChannelsagain. A repeatedchannel,privateorjoinfor a name the fake still holds now returns the same handle and records no second entry insubscribedChannels, as the real driver does.- A websocket error on the Reverb driver reaches each interceptor's
onErroronce; it used to run twice for one error. - A
BroadcastInterceptorwhoseonSendreturns an empty map now suppresses the frame, and aBroadcastEventreturned fromonErrornow reaches the listeners of its channel, as the contract promised. - A websocket frame that is not JSON, or a handshake with a missing or non-string field, no longer escapes as an uncaught error: it is logged as a warning, passed to the interceptors'
onError, and the connection keeps delivering events. An error thrown by an interceptor'sonReceive,onSendoronErrorstill reaches the app's zone, andonErrorruns once per error. - The documentation now says that
listencompares its event name with the frame's event name exactly and resolves no namespace, unlike Echo JS. A Laravel event withoutbroadcastAs()arrives as its full class name, so the samples now assume abroadcastAs()and the README and the Channels page show it and list the difference from Laravel Echo. - The documentation no longer claims that
Echo.fakesurvivesMagic.flush(): the fake lives in the container and the flush drops it; only theBroadcastListenersregistry, the custom drivers and aMagicPerfHooks.sinka test sets are statics to reset. - The custom driver guide counts three obligations of the driver contract, not two.
1.0.0 - 2026-11-14 #
Added #
- First release. Real-time broadcasting for Magic apps, moved out of
magiccore 1.0.0. Echofacade: public, private and presence channels over a Laravel Reverb (Pusher protocol) websocket, automatic reconnection, connection state and reconnect streams, and message interceptors.- A
nulldriver andEcho.fake(withpackage:magic_socket/testing.dart) so the same code runs and tests without a server. BroadcastServiceProvider, thebroadcastingConfigconfig factory, theListensToBroadcastscontroller mixin,BroadcastListenersandAuthChannelSubscription.SocketIdInterceptor, which addsX-Socket-IDtoHttprequests so Laravel'stoOthers()skips the sending device.- A
dowelplugin provider (MagicSocketDowelProvider) thatdart run magic:dowel plugin:install magic_socketregisters. - Built on
web_socket_channel^3.0.3 anddowel^1.0.0. Requires Dart 3.13, Flutter 3.47 andmagic^1.0.0.