Attempt to fix warnings not being sent, add a method for non-intrusive alerts
This commit is contained in:
parent
f976346b2d
commit
45233bd989
3 changed files with 14 additions and 13 deletions
|
@ -33,7 +33,7 @@ enum WarnIntervals {
|
||||||
warning: "The server has 10 seconds until restart"),
|
warning: "The server has 10 seconds until restart"),
|
||||||
TWENTY_SECONDS(
|
TWENTY_SECONDS(
|
||||||
seconds: 20,
|
seconds: 20,
|
||||||
type: WarnType.Intrusive,
|
type: WarnType.NonIntrusive,
|
||||||
warning: "The server is about to go down in 20 seconds"),
|
warning: "The server is about to go down in 20 seconds"),
|
||||||
THIRTY_SECONDS(
|
THIRTY_SECONDS(
|
||||||
seconds: 30,
|
seconds: 30,
|
||||||
|
@ -41,7 +41,7 @@ enum WarnIntervals {
|
||||||
warning: "The server will restart in 30 seconds"),
|
warning: "The server will restart in 30 seconds"),
|
||||||
ONE_MINUTE(
|
ONE_MINUTE(
|
||||||
seconds: 60,
|
seconds: 60,
|
||||||
type: WarnType.NonIntrusive,
|
type: WarnType.Intrusive,
|
||||||
warning: "The server will restart in 1 minute"),
|
warning: "The server will restart in 1 minute"),
|
||||||
FIVE_MIN(
|
FIVE_MIN(
|
||||||
seconds: (5 * 60),
|
seconds: (5 * 60),
|
||||||
|
@ -247,7 +247,9 @@ class StateMachine {
|
||||||
WarnIntervals current = SessionData.CURRENT_INTERVAL;
|
WarnIntervals current = SessionData.CURRENT_INTERVAL;
|
||||||
bool send = false;
|
bool send = false;
|
||||||
for (WarnIntervals WI in WarnIntervals.values) {
|
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;
|
current = WI;
|
||||||
send = true;
|
send = true;
|
||||||
|
|
||||||
|
@ -277,6 +279,10 @@ class StateMachine {
|
||||||
if (current.type == WarnType.Intrusive) {
|
if (current.type == WarnType.Intrusive) {
|
||||||
print("Sending alert '${current.warning}'");
|
print("Sending alert '${current.warning}'");
|
||||||
settings.sendRconCommand("broadcast ${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}\"");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import 'dart:convert';
|
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:libac_dart/utils/IOTools.dart';
|
import 'package:libac_dart/utils/IOTools.dart';
|
||||||
|
@ -88,14 +87,10 @@ Future<void> runDetachedWine(
|
||||||
workingDirectory: workingDir,
|
workingDirectory: workingDir,
|
||||||
mode: ProcessStartMode.detachedWithStdio);
|
mode: ProcessStartMode.detachedWithStdio);
|
||||||
|
|
||||||
StateMachine.PROC!.stdout
|
try {
|
||||||
.transform(utf8.decoder)
|
StateMachine.PROC!.stdout.forEach((line) {});
|
||||||
.transform(LineSplitter())
|
StateMachine.PROC!.stderr.forEach((line) {});
|
||||||
.forEach((line) {});
|
} catch (E) {}
|
||||||
StateMachine.PROC!.stderr
|
|
||||||
.transform(utf8.decoder)
|
|
||||||
.transform(LineSplitter())
|
|
||||||
.forEach((line) {});
|
|
||||||
|
|
||||||
StateMachine.monitorProcess();
|
StateMachine.monitorProcess();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
@ -40,7 +40,7 @@ dependencies:
|
||||||
crypto:
|
crypto:
|
||||||
libac_dart:
|
libac_dart:
|
||||||
hosted: https://git.zontreck.com/api/packages/AriasCreations/pub/
|
hosted: https://git.zontreck.com/api/packages/AriasCreations/pub/
|
||||||
version: 1.0.30
|
version: 1.0.33
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
|
Loading…
Reference in a new issue