Make some changes to prevent crash
This commit is contained in:
parent
bfa54b4804
commit
ee60a52249
1 changed files with 11 additions and 7 deletions
|
@ -98,15 +98,19 @@ class PacketClient {
|
||||||
CompoundTag ct = CompoundTag();
|
CompoundTag ct = CompoundTag();
|
||||||
Completer<void> onCompletion = Completer();
|
Completer<void> onCompletion = Completer();
|
||||||
socket!.listen((data) async {
|
socket!.listen((data) async {
|
||||||
CompoundTag result = await NbtIo.readFromStream(data);
|
try {
|
||||||
|
CompoundTag result = await NbtIo.readFromStream(data);
|
||||||
|
|
||||||
StringBuilder builder = StringBuilder();
|
StringBuilder builder = StringBuilder();
|
||||||
Tag.writeStringifiedNamedTag(result, builder, 0);
|
Tag.writeStringifiedNamedTag(result, builder, 0);
|
||||||
|
|
||||||
print("Response from server: \n${builder}");
|
print("Response from server: \n${builder}");
|
||||||
ct.put("result", result);
|
ct.put("result", result);
|
||||||
|
} catch (E, S) {
|
||||||
onCompletion.complete();
|
print(S);
|
||||||
|
} finally {
|
||||||
|
onCompletion.complete();
|
||||||
|
}
|
||||||
}, onError: (E, stack) {
|
}, onError: (E, stack) {
|
||||||
print("ERROR: ${E}\n${stack}");
|
print("ERROR: ${E}\n${stack}");
|
||||||
if (!onCompletion.isCompleted) onCompletion.complete();
|
if (!onCompletion.isCompleted) onCompletion.complete();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue