Add some more verbosity to the server

This commit is contained in:
zontreck 2024-05-23 11:25:14 -07:00
parent cc151e9109
commit 86386f97a2
2 changed files with 19 additions and 4 deletions

View file

@ -35,11 +35,19 @@ class PacketServer {
PacketResponse reply = await request.handleServerPacket();
// Server uses NBT to communicate
builder = StringBuilder();
Tag.writeStringifiedNamedTag(reply.replyDataTag, builder, 0);
print("Response to client: \n${builder}");
sock.add(await NbtIo.writeToStream(reply.replyDataTag));
} catch (E, stack) {
response.contents
.put("error", StringTag.valueOf("Malformed request packet"));
print(
"Something went wrong, sending malformed request response\n${stack}\n\n${E}\n\n");
sock.add(
await NbtIo.writeToStream(response.encodeTag() as CompoundTag));
} finally {
@ -94,12 +102,19 @@ class PacketClient {
Completer<void> onCompletion = Completer();
socket!.listen((data) async {
CompoundTag result = await NbtIo.readFromStream(data);
StringBuilder builder = StringBuilder();
Tag.writeStringifiedNamedTag(result, builder, 0);
print("Response from server: \n${builder}");
ct.put("result", result);
}, onError: (E) {
print("ERROR: ${E}");
onCompletion.complete();
}, onError: (E, stack) {
print("ERROR: ${E}\n${stack}");
if (!onCompletion.isCompleted) onCompletion.complete();
}, onDone: () {
print("Request completed");
onCompletion.complete();
});
await onCompletion.future;

View file

@ -1,6 +1,6 @@
name: libac_flutter
description: "Aria's Creations code library"
version: 1.0.13
version: 1.0.14
homepage: "https://zontreck.com"
environment: