diff --git a/bin/langsync.exe b/bin/langsync.exe index 16b2073..0fa645f 100644 Binary files a/bin/langsync.exe and b/bin/langsync.exe differ diff --git a/lib/src/commands/start_command/start_command.dart b/lib/src/commands/start_command/start_command.dart index 8ab4817..cd828d7 100644 --- a/lib/src/commands/start_command/start_command.dart +++ b/lib/src/commands/start_command/start_command.dart @@ -223,7 +223,7 @@ class StartCommand extends Command { 'message': 'Please, if you think that this is an unexpected bug in LangSync, contact us so we can help', 'partitionId': partitionId, - 'processedResponse': current.jsonFormattedResponse.toString(), + 'processedResponse': current.jsonFormattedResponse, 'target_language': current.lang, 'success_file_name': '${current.lang}.json', 'LocalizationTryDate': { @@ -272,16 +272,21 @@ class StartCommand extends Command { apiKey: apiKey, langs: langs, jsonPartitionId: partitionId, + languageLocalizationMaxDelay: languageLocalizationMaxDelay, ); LangSyncServerResultSSE? resultSSE; processStream.listen( - (event) { - if (event is LangSyncServerResultSSE) { - resultSSE = event; - } else { - logger.info(event.message); + (events) { + for (var i = 0; i < events.length; i++) { + final curr = events[i]; + + if (curr is LangSyncServerResultSSE) { + resultSSE = curr; + } else { + logger.info(curr.message); + } } }, onDone: () { diff --git a/lib/src/etc/networking/client.dart b/lib/src/etc/networking/client.dart index 9750418..c1392be 100644 --- a/lib/src/etc/networking/client.dart +++ b/lib/src/etc/networking/client.dart @@ -41,14 +41,14 @@ class NetClient extends NetClientBoilerPlate { }); } - Stream startAIProcess({ + Stream> startAIProcess({ required Iterable langs, required String apiKey, required String jsonPartitionId, required int? languageLocalizationMaxDelay, bool includeOutput = false, }) { - return sseStreamReq( + return sseStreamReq>( '/process-translation', 'POST', {'Authorization': 'Bearer $apiKey'}, @@ -59,9 +59,14 @@ class NetClient extends NetClientBoilerPlate { 'languageLocalizationMaxDelay': languageLocalizationMaxDelay, }, (res) { - final decoded = jsonDecode(res) as Map; + final split = res.split('\n\n').where((element) => element.isNotEmpty); - return LangSyncServerSSE.fromJson(decoded); + return split.map((event) { + final decodedEvent = jsonDecode(event.trim().replaceAll('\n', '')) + as Map; + + return LangSyncServerSSE.fromJson(decodedEvent); + }).toList(); }, ); } diff --git a/lib/src/etc/utils.dart b/lib/src/etc/utils.dart index 8951c49..7185fb4 100644 --- a/lib/src/etc/utils.dart +++ b/lib/src/etc/utils.dart @@ -12,7 +12,7 @@ class Utils { //! notice the "/" String get baseUrl => - isDebugMode ? 'http://192.168.0.2:5559' : 'http://test.langsync.app:5560'; + isDebugMode ? 'http://192.168.0.4:5559' : 'http://api.langsync.app'; bool isValidApiKeyFormatted(String apiKey) { final isNotEmpty = apiKey.isNotEmpty;