@@ -5,15 +5,14 @@ import 'dart:math' as math;
55import 'package:equatable/equatable.dart' ;
66import 'package:faye_dart/faye_dart.dart' ;
77import 'package:faye_dart/src/channel.dart' ;
8+ import 'package:faye_dart/src/extensible.dart' ;
89import 'package:faye_dart/src/message.dart' ;
910import 'package:faye_dart/src/timeout_helper.dart' ;
1011import 'package:logging/logging.dart' ;
1112import 'package:meta/meta.dart' ;
1213import 'package:web_socket_channel/status.dart' as status;
1314import 'package:web_socket_channel/web_socket_channel.dart' ;
1415
15- import 'package:faye_dart/src/extensible.dart' ;
16-
1716/// Connexion status of the client
1817enum FayeClientState {
1918 unconnected,
@@ -67,7 +66,7 @@ class FayeClient with Extensible, TimeoutHelper, EquatableMixin {
6766 final int retry;
6867 final _channels = < String , Channel > {};
6968
70- var _advice = Advice (
69+ var _advice = const Advice (
7170 reconnect: Advice .retry,
7271 interval: 1000 * defaultConnectionInterval,
7372 timeout: 1000 * defaultConnectionTimeout,
@@ -113,7 +112,7 @@ class FayeClient with Extensible, TimeoutHelper, EquatableMixin {
113112
114113 void _initWebSocketChannel () {
115114 _manuallyClosed = false ;
116- _logger.info (" Initiating connection with $baseUrl " );
115+ _logger.info (' Initiating connection with $baseUrl ' );
117116 if (_webSocketChannel != null ) {
118117 _closeWebSocketChannel ();
119118 }
@@ -129,7 +128,7 @@ class FayeClient with Extensible, TimeoutHelper, EquatableMixin {
129128 cancelAllTimeout ();
130129
131130 if (_webSocketChannel != null ) {
132- _logger.info (" Closing connection for $baseUrl " );
131+ _logger.info (' Closing connection for $baseUrl ' );
133132 _unsubscribeFromWebsocket ();
134133 _webSocketChannel? .sink.close (status.goingAway);
135134 _webSocketChannel = null ;
@@ -150,10 +149,8 @@ class FayeClient with Extensible, TimeoutHelper, EquatableMixin {
150149
151150 void _unsubscribeFromWebsocket () {
152151 _logger.info ('Stopped listening to $baseUrl ' );
153- if (_websocketSubscription != null ) {
154- _websocketSubscription! .cancel ();
155- _websocketSubscription = null ;
156- }
152+ _websocketSubscription? .cancel ();
153+ _websocketSubscription = null ;
157154 }
158155
159156 void _onDataReceived (dynamic data) {
@@ -194,7 +191,7 @@ class FayeClient with Extensible, TimeoutHelper, EquatableMixin {
194191
195192 _initWebSocketChannel ();
196193
197- _logger.info (" Initiating handshake with $baseUrl " );
194+ _logger.info (' Initiating handshake with $baseUrl ' );
198195
199196 _sendMessage (
200197 Message (
@@ -279,7 +276,9 @@ class FayeClient with Extensible, TimeoutHelper, EquatableMixin {
279276 }
280277
281278 void _subscribeChannels (Iterable <String > channels, {bool force = false }) {
282- for (final channel in channels) subscribe (channel, force: force);
279+ for (final channel in channels) {
280+ subscribe (channel, force: force);
281+ }
283282 }
284283
285284 Future <Subscription > subscribe (
@@ -390,7 +389,7 @@ class FayeClient with Extensible, TimeoutHelper, EquatableMixin {
390389 final id = _generateMessageId ();
391390 message.id = id;
392391 pipeThroughExtensions ('outgoing' , message, (message) {
393- _logger.info (" sending message : $message " );
392+ _logger.info (' sending message : $message ' );
394393 if (onResponse != null ) _responseCallbacks[id] = onResponse;
395394 final data = jsonEncode (message);
396395 _webSocketChannel? .sink.add (data);
@@ -404,7 +403,7 @@ class FayeClient with Extensible, TimeoutHelper, EquatableMixin {
404403 callback = _responseCallbacks.remove (id);
405404 }
406405 pipeThroughExtensions ('incoming' , message, (message) {
407- _logger.info (" received message : $message " );
406+ _logger.info (' received message : $message ' );
408407 if (message.advice != null ) _handleAdvice (message.advice! );
409408 _deliverMessage (message);
410409 callback? .call (message);
@@ -435,7 +434,7 @@ class FayeClient with Extensible, TimeoutHelper, EquatableMixin {
435434 _connectRequestInProgress = false ;
436435 _logger.info ('Closed connection for $_clientId ' );
437436 }
438- setTimeout (Duration (milliseconds: _advice.interval), () => connect () );
437+ setTimeout (Duration (milliseconds: _advice.interval), connect);
439438 }
440439
441440 @override
0 commit comments