autoformatting

This commit is contained in:
sneurlax 2023-07-27 13:43:25 -05:00
parent 59379faa4c
commit 571fd960b8
2 changed files with 17 additions and 12 deletions

View file

@ -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<void> sendMessageWithSocketWrapper(
@ -198,9 +200,9 @@ class Connection {
return recvBuf;
}
Future<List<int>> recv_message2(SocketWrapper socketwrapper, {Duration? timeout}) async {
print ("START OF RECV2");
Future<List<int>> 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

View file

@ -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<void> initializeConnection(String host, int port) async {
Socket socket = await Socket.connect(host, port);
@ -785,8 +788,7 @@ class Fusion {
}
Future<void> 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 = <String>[];
var displayMid = <String>[];
var displayQueued = <String>[];