Adds a instruction to prevent automatically reconnecting the client to the server
This commit is contained in:
parent
4de135284f
commit
043010aad3
2 changed files with 4 additions and 3 deletions
|
@ -10,14 +10,14 @@ void main() async {
|
|||
PacketClient client = PacketClient();
|
||||
await client.startConnect("127.0.0.1");
|
||||
|
||||
S2CResponse response = await client.send(C2SPing());
|
||||
S2CResponse response = await client.send(C2SPing(), true);
|
||||
CompoundTag tag = response.contents;
|
||||
StringBuilder builder = StringBuilder();
|
||||
Tag.writeStringifiedNamedTag(tag, builder, 0);
|
||||
|
||||
print("Response from server: \n${builder}");
|
||||
|
||||
await client.send(StopServerPacket());
|
||||
await client.send(StopServerPacket(), false);
|
||||
|
||||
if (client.connected) await client.close();
|
||||
return;
|
||||
|
|
|
@ -91,7 +91,7 @@ class PacketClient {
|
|||
/// Tries to send a packet to the connected server
|
||||
///
|
||||
/// On success, returns either, the decoded [S2CResponse], or on error a S2CResponse containing an error and a stacktrace as [StringTag]
|
||||
Future<S2CResponse> send(IPacket packet) async {
|
||||
Future<S2CResponse> send(IPacket packet, bool shouldReconnect) async {
|
||||
if (!connected) {
|
||||
return S2CResponse();
|
||||
}
|
||||
|
@ -121,6 +121,7 @@ class PacketClient {
|
|||
|
||||
await onCompletion.future;
|
||||
await close();
|
||||
|
||||
await startConnect(lastIP);
|
||||
S2CResponse reply = S2CResponse();
|
||||
try {
|
||||
|
|
Loading…
Reference in a new issue