Skip to content

Commit

Permalink
⚡ Upgraded Embedded Core!
Browse files Browse the repository at this point in the history
  • Loading branch information
omegaui committed Mar 20, 2023
1 parent 2e16730 commit afc9ab1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
6 changes: 4 additions & 2 deletions lib/core/io/logger.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'dart:convert';
import 'dart:io';

const initError = 101;
const initSuccess = 102;
Expand All @@ -13,8 +14,9 @@ const chatSwitched = 301;
const chatCompanion = 302;
const serverClosing = -1;

void streamLog(int code, String message) {
print(createResponse(code, message));
Future<void> streamLog(int code, String message) async {
stdout.writeln(createResponse(code, message));
await stdout.flush();
}

String createResponse(int code, dynamic response, {dynamic cause}) {
Expand Down
8 changes: 4 additions & 4 deletions lib/core/server/server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ void main() async {
serverContext = await shelfRun(_initServer,
defaultBindAddress: config['host'],
defaultBindPort: config['port'],
onStartFailed: (e) =>
streamLog(initError, "Cannot Launch Server at this address!"),
onStarted: (address, portNumber) {
onStartFailed: (e) async =>
await streamLog(initError, "Cannot Launch Server at this address!"),
onStarted: (address, portNumber) async {
host = address.toString();
port = portNumber;
code = config['code'];
streamLog(initSuccess, "Server Started Successfully! $address");
await streamLog(initSuccess, "Server Started Successfully! $address");
},
onWillClose: () {
terminateAllSessions();
Expand Down

0 comments on commit afc9ab1

Please sign in to comment.