fix(style): Format using dart format

This commit is contained in:
PapaTutuWawa 2023-03-08 20:25:45 +01:00
parent 38155051f5
commit 8b0f118e2d

View File

@ -22,7 +22,8 @@ class TCPSocketWrapper extends BaseSocketWrapper {
final StreamController<String> _dataStream = StreamController.broadcast(); final StreamController<String> _dataStream = StreamController.broadcast();
/// The stream of outgoing (TCPSocketWrapper -> XmppConnection) events. /// The stream of outgoing (TCPSocketWrapper -> XmppConnection) events.
final StreamController<XmppSocketEvent> _eventStream = StreamController.broadcast(); final StreamController<XmppSocketEvent> _eventStream =
StreamController.broadcast();
/// A subscription on the socket's data stream. /// A subscription on the socket's data stream.
StreamSubscription<dynamic>? _socketSubscription; StreamSubscription<dynamic>? _socketSubscription;
@ -80,7 +81,9 @@ class TCPSocketWrapper extends BaseSocketWrapper {
results.sort(srvRecordSortComparator); results.sort(srvRecordSortComparator);
for (final srv in results) { for (final srv in results) {
try { try {
_log.finest('Attempting secure connection to ${srv.target}:${srv.port}...'); _log.finest(
'Attempting secure connection to ${srv.target}:${srv.port}...',
);
// Workaround: We cannot set the SNI directly when using SecureSocket.connect. // Workaround: We cannot set the SNI directly when using SecureSocket.connect.
// instead, we connect using a regular socket and then secure it. This allows // instead, we connect using a regular socket and then secure it. This allows
@ -93,14 +96,14 @@ class TCPSocketWrapper extends BaseSocketWrapper {
_socket = await SecureSocket.secure( _socket = await SecureSocket.secure(
sock, sock,
host: domain, host: domain,
supportedProtocols: const [ xmppClientALPNId ], supportedProtocols: const [xmppClientALPNId],
onBadCertificate: (cert) => onBadCertificate(cert, domain), onBadCertificate: (cert) => onBadCertificate(cert, domain),
); );
_secure = true; _secure = true;
_log.finest('Success!'); _log.finest('Success!');
return true; return true;
} on Exception catch(e) { } on Exception catch (e) {
_log.finest('Failure! $e'); _log.finest('Failure! $e');
if (e is HandshakeException) { if (e is HandshakeException) {
@ -132,7 +135,7 @@ class TCPSocketWrapper extends BaseSocketWrapper {
_log.finest('Success!'); _log.finest('Success!');
return true; return true;
} on Exception catch(e) { } on Exception catch (e) {
_log.finest('Failure! $e'); _log.finest('Failure! $e');
continue; continue;
} }
@ -154,7 +157,7 @@ class TCPSocketWrapper extends BaseSocketWrapper {
); );
_log.finest('Success!'); _log.finest('Success!');
return true; return true;
} on Exception catch(e) { } on Exception catch (e) {
_log.finest('Failure! $e'); _log.finest('Failure! $e');
return false; return false;
} }
@ -187,7 +190,7 @@ class TCPSocketWrapper extends BaseSocketWrapper {
_socket = await SecureSocket.secure( _socket = await SecureSocket.secure(
_socket!, _socket!,
supportedProtocols: const [ xmppClientALPNId ], supportedProtocols: const [xmppClientALPNId],
onBadCertificate: (cert) => onBadCertificate(cert, domain), onBadCertificate: (cert) => onBadCertificate(cert, domain),
); );
@ -232,7 +235,7 @@ class TCPSocketWrapper extends BaseSocketWrapper {
} }
@override @override
Future<bool> connect(String domain, { String? host, int? port }) async { Future<bool> connect(String domain, {String? host, int? port}) async {
_expectSocketClosure = false; _expectSocketClosure = false;
_secure = false; _secure = false;
@ -280,7 +283,7 @@ class TCPSocketWrapper extends BaseSocketWrapper {
try { try {
_socket!.close(); _socket!.close();
} catch(e) { } catch (e) {
_log.warning('Closing socket threw exception: $e'); _log.warning('Closing socket threw exception: $e');
} }
} }
@ -289,10 +292,11 @@ class TCPSocketWrapper extends BaseSocketWrapper {
Stream<String> getDataStream() => _dataStream.stream.asBroadcastStream(); Stream<String> getDataStream() => _dataStream.stream.asBroadcastStream();
@override @override
Stream<XmppSocketEvent> getEventStream() => _eventStream.stream.asBroadcastStream(); Stream<XmppSocketEvent> getEventStream() =>
_eventStream.stream.asBroadcastStream();
@override @override
void write(Object? data, { String? redact }) { void write(Object? data, {String? redact}) {
if (_socket == null) { if (_socket == null) {
_log.severe('Failed to write to socket as _socket is null'); _log.severe('Failed to write to socket as _socket is null');
return; return;