Attempt to fix warnings not being sent, add a method for non-intrusive alerts

This commit is contained in:
zontreck 2024-06-09 05:04:35 -07:00
parent f976346b2d
commit 45233bd989
3 changed files with 14 additions and 13 deletions

View file

@ -33,7 +33,7 @@ enum WarnIntervals {
warning: "The server has 10 seconds until restart"),
TWENTY_SECONDS(
seconds: 20,
type: WarnType.Intrusive,
type: WarnType.NonIntrusive,
warning: "The server is about to go down in 20 seconds"),
THIRTY_SECONDS(
seconds: 30,
@ -41,7 +41,7 @@ enum WarnIntervals {
warning: "The server will restart in 30 seconds"),
ONE_MINUTE(
seconds: 60,
type: WarnType.NonIntrusive,
type: WarnType.Intrusive,
warning: "The server will restart in 1 minute"),
FIVE_MIN(
seconds: (5 * 60),
@ -247,7 +247,9 @@ class StateMachine {
WarnIntervals current = SessionData.CURRENT_INTERVAL;
bool send = false;
for (WarnIntervals WI in WarnIntervals.values) {
if (WI.seconds <= sec && WI.seconds <= current.seconds) {
if (WI == WarnIntervals.NONE) continue;
if (WI.seconds >= sec && WI.seconds <= current.seconds) {
current = WI;
send = true;
@ -277,6 +279,10 @@ class StateMachine {
if (current.type == WarnType.Intrusive) {
print("Sending alert '${current.warning}'");
settings.sendRconCommand("broadcast ${current.warning}");
} else if (current.type == WarnType.NonIntrusive) {
print("Sending chat message '${current.warning}'");
settings.sendRconCommand(
"ast chat \"global\" \"${current.warning}\"");
}
}

View file

@ -1,4 +1,3 @@
import 'dart:convert';
import 'dart:io';
import 'package:libac_dart/utils/IOTools.dart';
@ -88,14 +87,10 @@ Future<void> runDetachedWine(
workingDirectory: workingDir,
mode: ProcessStartMode.detachedWithStdio);
StateMachine.PROC!.stdout
.transform(utf8.decoder)
.transform(LineSplitter())
.forEach((line) {});
StateMachine.PROC!.stderr
.transform(utf8.decoder)
.transform(LineSplitter())
.forEach((line) {});
try {
StateMachine.PROC!.stdout.forEach((line) {});
StateMachine.PROC!.stderr.forEach((line) {});
} catch (E) {}
StateMachine.monitorProcess();
} catch (e) {

View file

@ -40,7 +40,7 @@ dependencies:
crypto:
libac_dart:
hosted: https://git.zontreck.com/api/packages/AriasCreations/pub/
version: 1.0.30
version: 1.0.33
dev_dependencies:
flutter_test: