mirror of
https://github.com/collinsmith/riiablo.git
synced 2025-01-22 02:07:26 +07:00
Added sendDisconnectPacket function to D2GS TestClient
This commit is contained in:
parent
26173a8fd1
commit
88b8e7a096
@ -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());
|
||||
|
Loading…
Reference in New Issue
Block a user