Skip to content

Commit

Permalink
formatted #188
Browse files Browse the repository at this point in the history
  • Loading branch information
DevKevYT committed Oct 7, 2022
1 parent 14fa3ed commit ce8cd32
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
14 changes: 6 additions & 8 deletions lib/core/excel/solc_api_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -107,25 +107,24 @@ class SOLCApiManager {
try {
_activeSockets = _activeSockets + 1;
final socket = await Socket.connect(_inetAddress, _port);

//Sende den Befehl
socket.writeln(command);
await socket.flush();

void throwException(Exception e) {
exception = e;
socket.close();
}

bool awaitFileStream = false;

if (downloadBytes != null) {
downloadBytes.clear();
}

var subscription = socket.listen(
(event) async {

if (awaitFileStream) {
if (downloadBytes == null) {
throwException(DownloadFileNotFoundException("Kein Ziel zum Download angegeben"));
Expand Down Expand Up @@ -190,16 +189,15 @@ class SOLCApiManager {
await subscription.asFuture<void>().timeout(const Duration(seconds: timeoutSeconds), onTimeout: () {
throwException(SOLCServerResponseTimeoutException("Timeout after $timeoutSeconds seconds"));
});

await socket.close();
await subscription.cancel();

_activeSockets--;
log.d("Connection for SOLC command '$command' closed. $_activeSockets active connections.");

} on Exception catch (error) {
_activeSockets--;
throw FailedToEstablishSOLCServerConnection (
throw FailedToEstablishSOLCServerConnection(
"Konnte keine Verbindung zum Konvertierungsserver $_inetAddress herstellen: $error");
}
if (exception != null) {
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/screens/settings/settings.screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class SettingsScreen extends ConsumerWidget {
log.d("Checking file status on server ...");
try {
PhaseStatus? status = await manager.getSchoolClassInfo(schoolClassId: schoolClassId);

if (DateTime.now().millisecondsSinceEpoch >= status!.blockEnd.millisecondsSinceEpoch) {
ScaffoldMessenger.of(context).clearSnackBars();
ScaffoldMessenger.of(context).showSnackBar(
Expand Down

0 comments on commit ce8cd32

Please sign in to comment.