From 571fd960b8fb9bfdb660553bd280518d06c4572a Mon Sep 17 00:00:00 2001 From: sneurlax Date: Thu, 27 Jul 2023 13:43:25 -0500 Subject: [PATCH] autoformatting --- lib/services/cashfusion/connection.dart | 10 ++++++---- lib/services/cashfusion/fusion.dart | 19 +++++++++++-------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/lib/services/cashfusion/connection.dart b/lib/services/cashfusion/connection.dart index 69da5fc7e..e6b9581c0 100644 --- a/lib/services/cashfusion/connection.dart +++ b/lib/services/cashfusion/connection.dart @@ -53,7 +53,9 @@ class Connection { static final Uint8List magic = Uint8List.fromList([0x76, 0x5b, 0xe8, 0xb4, 0xe4, 0x39, 0x6d, 0xcf]); final Uint8List recvbuf = Uint8List(0); + Connection({required this.socket, this.timeout = const Duration(seconds: 1)}); + Connection.withoutSocket({this.timeout = const Duration(seconds: 1)}); Future sendMessageWithSocketWrapper( @@ -198,9 +200,9 @@ class Connection { return recvBuf; } - - Future> recv_message2(SocketWrapper socketwrapper, {Duration? timeout}) async { - print ("START OF RECV2"); + Future> recv_message2(SocketWrapper socketwrapper, + {Duration? timeout}) async { + print("START OF RECV2"); if (timeout == null) { timeout = this.timeout; } @@ -264,7 +266,7 @@ class Connection { //print("DEBUG recv_message2 4 - message received, length: ${message.length}"); //print("DEBUG recv_message2 5 - message content: $message"); - print ("END OF RECV2"); + print("END OF RECV2"); return message; } else { // Throwing exception if the length doesn't match diff --git a/lib/services/cashfusion/fusion.dart b/lib/services/cashfusion/fusion.dart index 4fab9fbaf..1ce397a71 100644 --- a/lib/services/cashfusion/fusion.dart +++ b/lib/services/cashfusion/fusion.dart @@ -23,7 +23,9 @@ import 'validation.dart'; class FusionError implements Exception { final String message; + FusionError(this.message); + String toString() => "FusionError: $message"; } @@ -215,6 +217,7 @@ class Fusion { Fusion() { //initializeConnection(host, port) } + /* Future initializeConnection(String host, int port) async { Socket socket = await Socket.connect(host, port); @@ -785,8 +788,7 @@ class Fusion { } Future registerAndWait(SocketWrapper socketwrapper) async { - - print ("DEBUG register and wait top."); + print("DEBUG register and wait top."); // msg can be different classes depending on which protobuf msg is sent. dynamic? msg; @@ -826,8 +828,9 @@ class Fusion { }; while (true) { - print ("RECEIVE LOOP 870............DEBUG"); - var msg = await recv2(socketwrapper,['tierstatusupdate', 'fusionbegin'], timeout: Duration(seconds: 10)); + print("RECEIVE LOOP 870............DEBUG"); + var msg = await recv2(socketwrapper, ['tierstatusupdate', 'fusionbegin'], + timeout: Duration(seconds: 10)); var fieldInfoFusionBegin = msg.info_.byName["fusionbegin"]; if (fieldInfoFusionBegin != null && @@ -865,7 +868,8 @@ class Fusion { int? besttime; int? besttimetier; for (var entry in statuses.entries) { - double frac = entry.value.players.toInt() / entry.value.minPlayers.toInt(); + double frac = + entry.value.players.toInt() / entry.value.minPlayers.toInt(); if (frac >= maxfraction) { if (frac > maxfraction) { maxfraction = frac; @@ -876,11 +880,11 @@ class Fusion { var fieldInfoTimeRemaining = entry.value.info_.byName["timeRemaining"]; if (fieldInfoTimeRemaining == null) { - throw FusionError('Expected field not found in message: timeRemaining'); + throw FusionError( + 'Expected field not found in message: timeRemaining'); } if (entry.value.hasField(fieldInfoTimeRemaining.tagNumber)) { - int tr = entry.value.timeRemaining.toInt(); if (besttime == null || tr < besttime) { besttime = tr; @@ -889,7 +893,6 @@ class Fusion { } } - var displayBest = []; var displayMid = []; var displayQueued = [];