adapter_websocket 0.1.4
adapter_websocket: ^0.1.4 copied to clipboard
A Flutter WebSocket adapter with auto-reconnect, heartbeat, interceptors, ACK confirmation, message queuing, topic multiplexing, and connection pooling.
0.1.4 #
Improvements #
- Removed unused plugin scaffold files (
adapter_websocket_web.dart,untitled5_method_channel.dart,websocket_platform_interface.dart) that were generated byflutter create --template=pluginbut never wired into actual functionality. - Removed corresponding unused dependencies:
flutter_web_plugins,plugin_platform_interface. - Removed the empty web plugin class registration from
pubspec.yaml; web WebSocket support continues to work throughweb_socket_channel.
0.1.3 #
Improvements #
- Refactored
WebSocketChannelAdapterinternals to fully support the WASM platform, removing remainingdart:iodependencies from the connection path via conditional imports. - Improved
CompressionInterceptorreliability on native platforms. - Added GitHub Pages live demo (automatically deployed on every push to
master).
0.1.2 #
Bug Fixes #
- Fixed
CompressionInterceptornot actually applying gzip on native platforms — replaced stub with proper conditional import ofdart:ioGZipCodec. - Fixed
library_private_types_in_public_apilint violations inAckManagerandWebSocketTopicconstructors by inlining function types. - Removed unnecessary
librarydirective fromwebsocket_plugin.dart.
Improvements #
- WASM compatibility: removed top-level
dart:iodependency fromWebSocketConfigandWebSocketChannelAdapterusing conditional imports; package now compiles for WASM targets. - Added Swift Package Manager support (
Package.swift) for iOS and macOS. WebSocketConfig.httpClientfield is now typed asObject?to avoid adart:ioimport in the public API; the native adapter casts it internally.
0.1.1 #
0.1.0 #
New Features #
- Interceptor / Middleware —
WebSocketInterceptorabstract class andInterceptorChainfor inspecting, transforming, or suppressing messages at send and receive time. Ships with a built-inLoggingInterceptor. - Message Queue (offline buffer) —
MessageQueuebuffers outgoing messages while the connection is down and automatically flushes them on reconnect. Configurable viaenableMessageQueue,maxQueueSize, andmessageQueueTimeout. - ACK Confirmation —
AckManagerinjects a unique__ack_id__into outgoing messages and waits for server acknowledgement. Supports configurable timeout and automatic retries. Configurable viaenableAck,ackTimeout, andmaxAckRetries. - Topic Multiplexing (Channel/Topic) —
ChannelManagerandWebSocketTopicenable multiple logical channels over a single WebSocket connection using a JSON envelope format ({"topic":"…","event":"…","payload":…}). Access viaclient.channel('topic:name'). - Compression —
CompressionInterceptortransparently gzip-compresses outgoing messages above a configurable byte threshold and decompresses incoming messages. Available on native platforms (not web). - Connection Pool —
WebSocketPoolmanages multipleWebSocketClientinstances across different server endpoints with round-robin, random, or least-connections load balancing. Supportsbroadcast()to all connected clients.
Improvements #
WebSocketConfig.copyWith()now includesexpectedPongMessagePattern.WebSocketClientmessage pipeline runs through the interceptor chain before sending and after receiving.WebSocketClient.send()andsendMessage()enqueue messages when disconnected (ifenableMessageQueueis enabled) instead of immediately throwing.- Queue is drained automatically on reconnect success (both from
connect()and from the reconnection manager). connectionStatsnow includesmessageQueue,ack,channels, andinterceptorsfields.
Bug Fixes #
- Fixed
_isHeartbeatMessage()null dereference when onlyexpectedPongMessagewas set. - Fixed
copyWith()droppingexpectedPongMessagePattern. - Fixed heartbeat pong waiting logic ignoring
expectedPongMessagePattern. - Fixed
handleIncomingMessage()not recognising pong responses matched byexpectedPongMessagePattern. - Fixed
WebSocketClient._publishStats()not being called after initiating reconnection from heartbeat timeout. - Fixed shadowed variable in
reconnection_manager_test.dartcausing NullPointerException. - Fixed
ReconnectionManagertimer leak between tests by addingtearDown. - Fixed
reconnection_manager_test.dart"max attempts" test not waiting long enough for exponential backoff. - Fixed
websocket_plugin_test.dartunstable-connection test relying on 30-second instability timer.
0.0.2 #
- TODO: Describe initial release.