Skip to content

Commit

Permalink
Refactor PendingConnection class
Browse files Browse the repository at this point in the history
  • Loading branch information
SupremeMortal committed Jul 24, 2024
1 parent baf053b commit b7fdbfb
Showing 1 changed file with 5 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ private void onOpenConnectionRequest2(ChannelHandlerContext ctx, DatagramPacket
boolean sendCookie = ((RakServerChannelConfig) ctx.channel().config()).getSendCookie();
if (sendCookie) {
int cookie = buffer.readInt();
int expectedCookie = connection.getCookie();
int expectedCookie = connection.cookie;
if (expectedCookie != cookie) {
if (log.isTraceEnabled()) {
log.trace("[{}] Received ID_OPEN_CONNECTION_REQUEST_2 with invalid cookie (expected {}, but received {})",
Expand Down Expand Up @@ -253,7 +253,7 @@ private void onOpenConnectionRequest2(ChannelHandlerContext ctx, DatagramPacket
}

RakServerChannel serverChannel = (RakServerChannel) ctx.channel();
RakChildChannel channel = serverChannel.createChildChannel(sender, clientGuid, connection.getProtocolVersion(), mtu);
RakChildChannel channel = serverChannel.createChildChannel(sender, clientGuid, connection.protocolVersion, mtu);
if (channel == null) {
if (log.isTraceEnabled()) {
log.trace("[{}] Received ID_OPEN_CONNECTION_REQUEST_2, but a channel already exists for this socket address",
Expand Down Expand Up @@ -291,21 +291,13 @@ private void sendAlreadyConnected(ChannelHandlerContext ctx, InetSocketAddress s
ctx.writeAndFlush(new DatagramPacket(buffer, sender));
}

private class PendingConnection {
private final int protocolVersion;
private final int cookie;
private static class PendingConnection {
final int protocolVersion;
final int cookie;

public PendingConnection(int protocolVersion, int cookie) {
this.protocolVersion = protocolVersion;
this.cookie = cookie;
}

public int getProtocolVersion() {
return this.protocolVersion;
}

public int getCookie() {
return this.cookie;
}
}
}

0 comments on commit b7fdbfb

Please sign in to comment.