From 88b8e7a096043d96988bde7353dd6d27445840ad Mon Sep 17 00:00:00 2001 From: Collin Smith Date: Sat, 27 Jun 2020 17:06:03 -0700 Subject: [PATCH] Added sendDisconnectPacket function to D2GS TestClient --- .../src/com/riiablo/server/d2gs/TestClient.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/server/netty/src/com/riiablo/server/d2gs/TestClient.java b/server/netty/src/com/riiablo/server/d2gs/TestClient.java index 32ca7384..6925d38d 100644 --- a/server/netty/src/com/riiablo/server/d2gs/TestClient.java +++ b/server/netty/src/com/riiablo/server/d2gs/TestClient.java @@ -26,6 +26,7 @@ import com.riiablo.net.EndpointedChannelHandler; import com.riiablo.net.PacketProcessor; import com.riiablo.net.UnicastEndpoint; import com.riiablo.net.packet.netty.Connection; +import com.riiablo.net.packet.netty.Disconnect; import com.riiablo.net.packet.netty.Netty; import com.riiablo.net.packet.netty.NettyData; import com.riiablo.net.reliable.QoS; @@ -70,6 +71,7 @@ public class TestClient extends ApplicationAdapter implements PacketProcessor { ChannelFuture f = b.connect("localhost", Main.PORT).sync(); sendConnectionPacket(); sendConnectionPacket(); + sendDisconnectPacket(); } catch (Throwable t) { Gdx.app.error(TAG, t.getMessage(), t); Gdx.app.exit(); @@ -91,6 +93,19 @@ public class TestClient extends ApplicationAdapter implements PacketProcessor { endpoint.sendMessage(QoS.Unreliable, builder.dataBuffer()); } + private void sendDisconnectPacket() { + SocketAddress remoteAddress = endpoint.channel().remoteAddress(); + Gdx.app.log(TAG, "Sending Disconnect packet to " + remoteAddress); + + FlatBufferBuilder builder = new FlatBufferBuilder(); + Disconnect.startDisconnect(builder); + int dataOffset = Disconnect.endDisconnect(builder); + int offset = Netty.createNetty(builder, 0L, NettyData.Disconnect, dataOffset); + Netty.finishSizePrefixedNettyBuffer(builder, offset); + + endpoint.sendMessage(QoS.Unreliable, builder.dataBuffer()); + } + @Override public void render() { endpoint.update(Gdx.graphics.getDeltaTime());