From 725bbe4a0187cd545f00778ccecfdbc91000f8ca Mon Sep 17 00:00:00 2001 From: Collin Smith Date: Wed, 24 Jun 2020 13:43:07 -0700 Subject: [PATCH] Modified API slightly to improve extension --- server/netty/src/com/riiablo/net/PacketSender.java | 2 ++ .../src/com/riiablo/net/reliable/ReliableEndpoint.java | 6 ++++-- server/netty/src/com/riiablo/net/reliable/TestClient.java | 4 +--- server/netty/src/com/riiablo/net/reliable/TestServer.java | 4 +--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/server/netty/src/com/riiablo/net/PacketSender.java b/server/netty/src/com/riiablo/net/PacketSender.java index 8180f32f..c4151d2b 100644 --- a/server/netty/src/com/riiablo/net/PacketSender.java +++ b/server/netty/src/com/riiablo/net/PacketSender.java @@ -1,8 +1,10 @@ package com.riiablo.net; +import io.netty.channel.Channel; import java.nio.ByteBuffer; public interface PacketSender { + Channel channel(); void sendMessage(ByteBuffer bb); void sendMessage(T qos, ByteBuffer bb); } diff --git a/server/netty/src/com/riiablo/net/reliable/ReliableEndpoint.java b/server/netty/src/com/riiablo/net/reliable/ReliableEndpoint.java index 73a573f3..2b8e11a3 100644 --- a/server/netty/src/com/riiablo/net/reliable/ReliableEndpoint.java +++ b/server/netty/src/com/riiablo/net/reliable/ReliableEndpoint.java @@ -2,6 +2,7 @@ package com.riiablo.net.reliable; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; +import io.netty.channel.Channel; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.socket.DatagramChannel; import io.netty.channel.socket.DatagramPacket; @@ -51,8 +52,9 @@ public class ReliableEndpoint implements PacketSender, MessageChannel.Packe return channel.remoteAddress(); } - public boolean isConnected() { - return channel.isConnected(); + @Override + public Channel channel() { + return channel; } public void reset() { diff --git a/server/netty/src/com/riiablo/net/reliable/TestClient.java b/server/netty/src/com/riiablo/net/reliable/TestClient.java index 1a546cdc..4cfc7c86 100644 --- a/server/netty/src/com/riiablo/net/reliable/TestClient.java +++ b/server/netty/src/com/riiablo/net/reliable/TestClient.java @@ -88,9 +88,7 @@ public class TestClient extends ApplicationAdapter implements PacketProcessor { @Override public void render() { - if (endpoint != null && endpoint.isConnected()) { - endpoint.update(Gdx.graphics.getDeltaTime()); - } + endpoint.update(Gdx.graphics.getDeltaTime()); } @Override diff --git a/server/netty/src/com/riiablo/net/reliable/TestServer.java b/server/netty/src/com/riiablo/net/reliable/TestServer.java index 2516413d..dad2a4b8 100644 --- a/server/netty/src/com/riiablo/net/reliable/TestServer.java +++ b/server/netty/src/com/riiablo/net/reliable/TestServer.java @@ -68,9 +68,7 @@ public class TestServer extends ApplicationAdapter implements PacketProcessor { @Override public void render() { - if (endpoint != null && endpoint.isConnected()) { - endpoint.update(Gdx.graphics.getDeltaTime()); - } + endpoint.update(Gdx.graphics.getDeltaTime()); } @Override