Modified API slightly to improve extension

This commit is contained in:
Collin Smith
2020-06-24 13:43:07 -07:00
parent 2f066cbd0f
commit 725bbe4a01
4 changed files with 8 additions and 8 deletions

View File

@ -1,8 +1,10 @@
package com.riiablo.net;
import io.netty.channel.Channel;
import java.nio.ByteBuffer;
public interface PacketSender<T> {
Channel channel();
void sendMessage(ByteBuffer bb);
void sendMessage(T qos, ByteBuffer bb);
}

View File

@ -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<QoS>, MessageChannel.Packe
return channel.remoteAddress();
}
public boolean isConnected() {
return channel.isConnected();
@Override
public Channel channel() {
return channel;
}
public void reset() {

View File

@ -88,10 +88,8 @@ public class TestClient extends ApplicationAdapter implements PacketProcessor {
@Override
public void render() {
if (endpoint != null && endpoint.isConnected()) {
endpoint.update(Gdx.graphics.getDeltaTime());
}
}
@Override
public void processPacket(ByteBuf bb) {

View File

@ -68,10 +68,8 @@ public class TestServer extends ApplicationAdapter implements PacketProcessor {
@Override
public void render() {
if (endpoint != null && endpoint.isConnected()) {
endpoint.update(Gdx.graphics.getDeltaTime());
}
}
@Override
public void processPacket(ByteBuf bb) {