mirror of
https://github.com/collinsmith/riiablo.git
synced 2025-07-08 23:07:46 +07:00
Added SocketAddress from parameter to packet callbacks
from paramter will be either TCP channel remote address or UDP packet sender
This commit is contained in:
@ -13,6 +13,7 @@ import io.netty.channel.socket.DatagramChannel;
|
||||
import io.netty.channel.socket.DatagramPacket;
|
||||
import io.netty.channel.socket.nio.NioDatagramChannel;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.SocketAddress;
|
||||
|
||||
import com.badlogic.gdx.Application;
|
||||
import com.badlogic.gdx.ApplicationAdapter;
|
||||
@ -93,7 +94,7 @@ public class TestClient extends ApplicationAdapter implements PacketProcessor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processPacket(ChannelHandlerContext ctx, ByteBuf bb) {
|
||||
public void processPacket(ChannelHandlerContext ctx, SocketAddress from, ByteBuf bb) {
|
||||
Gdx.app.debug(TAG, "Processing packet...");
|
||||
Gdx.app.log(TAG, ByteBufUtil.hexDump(bb));
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ import io.netty.channel.nio.NioEventLoopGroup;
|
||||
import io.netty.channel.socket.DatagramChannel;
|
||||
import io.netty.channel.socket.DatagramPacket;
|
||||
import io.netty.channel.socket.nio.NioDatagramChannel;
|
||||
import java.net.SocketAddress;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import com.badlogic.gdx.Application;
|
||||
@ -81,7 +82,7 @@ public class TestServer extends ApplicationAdapter implements PacketProcessor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processPacket(ChannelHandlerContext ctx, ByteBuf bb) {
|
||||
public void processPacket(ChannelHandlerContext ctx, SocketAddress from, ByteBuf bb) {
|
||||
Gdx.app.debug(TAG, "Processing packet...");
|
||||
Gdx.app.log(TAG, ByteBufUtil.hexDump(bb));
|
||||
|
||||
|
@ -13,6 +13,7 @@ import io.netty.channel.nio.NioEventLoopGroup;
|
||||
import io.netty.channel.socket.SocketChannel;
|
||||
import io.netty.channel.socket.nio.NioSocketChannel;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.SocketAddress;
|
||||
|
||||
import com.badlogic.gdx.Application;
|
||||
import com.badlogic.gdx.ApplicationAdapter;
|
||||
@ -95,7 +96,7 @@ public class TestClient extends ApplicationAdapter implements PacketProcessor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processPacket(ChannelHandlerContext ctx, ByteBuf bb) {
|
||||
public void processPacket(ChannelHandlerContext ctx, SocketAddress from, ByteBuf bb) {
|
||||
Gdx.app.debug(TAG, "Processing packet...");
|
||||
Gdx.app.log(TAG, ByteBufUtil.hexDump(bb));
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import io.netty.channel.EventLoopGroup;
|
||||
import io.netty.channel.nio.NioEventLoopGroup;
|
||||
import io.netty.channel.socket.SocketChannel;
|
||||
import io.netty.channel.socket.nio.NioServerSocketChannel;
|
||||
import java.net.SocketAddress;
|
||||
|
||||
import com.badlogic.gdx.Application;
|
||||
import com.badlogic.gdx.ApplicationAdapter;
|
||||
@ -81,7 +82,7 @@ public class TestServer extends ApplicationAdapter implements PacketProcessor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processPacket(ChannelHandlerContext ctx, ByteBuf bb) {
|
||||
public void processPacket(ChannelHandlerContext ctx, SocketAddress from, ByteBuf bb) {
|
||||
Gdx.app.debug(TAG, "Processing packet...");
|
||||
Gdx.app.log(TAG, " " + ByteBufUtil.hexDump(bb));
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ public class Main extends ApplicationAdapter implements PacketProcessor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processPacket(ChannelHandlerContext ctx, ByteBuf bb) {
|
||||
public void processPacket(ChannelHandlerContext ctx, SocketAddress from, ByteBuf bb) {
|
||||
Gdx.app.debug(TAG, "Processing packet...");
|
||||
Gdx.app.debug(TAG, " " + ByteBufUtil.hexDump(bb));
|
||||
processPacket(ctx, Netty.getRootAsNetty(bb.nioBuffer()));
|
||||
@ -136,7 +136,7 @@ public class Main extends ApplicationAdapter implements PacketProcessor {
|
||||
InetSocketAddress from = (InetSocketAddress) ctx.channel().remoteAddress();
|
||||
switch (netty.dataType()) {
|
||||
case NettyData.Connection: {
|
||||
Connection(from, netty);
|
||||
Connection(ctx, from, netty);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@ -145,7 +145,7 @@ public class Main extends ApplicationAdapter implements PacketProcessor {
|
||||
}
|
||||
}
|
||||
|
||||
private void Connection(InetSocketAddress from, Netty netty) {
|
||||
private void Connection(ChannelHandlerContext ctx, InetSocketAddress from, Netty netty) {
|
||||
Gdx.app.debug(TAG, "Connection from " + from);
|
||||
Connection connection = (Connection) netty.data(new Connection());
|
||||
|
||||
|
@ -13,6 +13,7 @@ import io.netty.channel.nio.NioEventLoopGroup;
|
||||
import io.netty.channel.socket.SocketChannel;
|
||||
import io.netty.channel.socket.nio.NioSocketChannel;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.SocketAddress;
|
||||
|
||||
import com.badlogic.gdx.Application;
|
||||
import com.badlogic.gdx.ApplicationAdapter;
|
||||
@ -103,7 +104,7 @@ public class TestClient extends ApplicationAdapter implements PacketProcessor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processPacket(ChannelHandlerContext ctx, ByteBuf bb) {
|
||||
public void processPacket(ChannelHandlerContext ctx, SocketAddress from, ByteBuf bb) {
|
||||
Gdx.app.debug(TAG, "Processing packet...");
|
||||
Gdx.app.log(TAG, ByteBufUtil.hexDump(bb));
|
||||
}
|
||||
|
Reference in New Issue
Block a user