Code polish/cleanup
This commit is contained in:
parent
64d41c8f02
commit
78dfa5ef3f
@ -32,6 +32,7 @@ import dorkbox.network.util.exceptions.SecurityException;
|
|||||||
import dorkbox.network.util.udt.UdtEndpointProxy;
|
import dorkbox.network.util.udt.UdtEndpointProxy;
|
||||||
import dorkbox.util.NamedThreadFactory;
|
import dorkbox.util.NamedThreadFactory;
|
||||||
import dorkbox.util.OS;
|
import dorkbox.util.OS;
|
||||||
|
import dorkbox.util.Sys;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -75,7 +76,7 @@ public class Server extends EndPointServer {
|
|||||||
super("Server", options);
|
super("Server", options);
|
||||||
|
|
||||||
Logger logger2 = this.logger;
|
Logger logger2 = this.logger;
|
||||||
if (isAndroid && options.udtPort > 0) {
|
if (Sys.isAndroid && options.udtPort > 0) {
|
||||||
// Android does not support UDT.
|
// Android does not support UDT.
|
||||||
if (logger2.isInfoEnabled()) {
|
if (logger2.isInfoEnabled()) {
|
||||||
logger2.info("Android does not support UDT.");
|
logger2.info("Android does not support UDT.");
|
||||||
@ -160,7 +161,7 @@ public class Server extends EndPointServer {
|
|||||||
EventLoopGroup boss;
|
EventLoopGroup boss;
|
||||||
EventLoopGroup worker;
|
EventLoopGroup worker;
|
||||||
|
|
||||||
if (isAndroid) {
|
if (Sys.isAndroid) {
|
||||||
// android ONLY supports OIO (not NIO)
|
// android ONLY supports OIO (not NIO)
|
||||||
boss = new OioEventLoopGroup(0, new NamedThreadFactory(this.name + "-boss-TCP", nettyGroup));
|
boss = new OioEventLoopGroup(0, new NamedThreadFactory(this.name + "-boss-TCP", nettyGroup));
|
||||||
worker = new OioEventLoopGroup(0, new NamedThreadFactory(this.name + "-worker-TCP", nettyGroup));
|
worker = new OioEventLoopGroup(0, new NamedThreadFactory(this.name + "-worker-TCP", nettyGroup));
|
||||||
@ -201,8 +202,8 @@ public class Server extends EndPointServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// android screws up on this!!
|
// android screws up on this!!
|
||||||
this.tcpBootstrap.option(ChannelOption.TCP_NODELAY, !isAndroid);
|
this.tcpBootstrap.option(ChannelOption.TCP_NODELAY, !Sys.isAndroid);
|
||||||
this.tcpBootstrap.childOption(ChannelOption.TCP_NODELAY, !isAndroid);
|
this.tcpBootstrap.childOption(ChannelOption.TCP_NODELAY, !Sys.isAndroid);
|
||||||
|
|
||||||
this.tcpBootstrap.childOption(ChannelOption.SO_KEEPALIVE, true);
|
this.tcpBootstrap.childOption(ChannelOption.SO_KEEPALIVE, true);
|
||||||
}
|
}
|
||||||
@ -211,7 +212,7 @@ public class Server extends EndPointServer {
|
|||||||
if (this.udpBootstrap != null) {
|
if (this.udpBootstrap != null) {
|
||||||
EventLoopGroup worker;
|
EventLoopGroup worker;
|
||||||
|
|
||||||
if (isAndroid) {
|
if (Sys.isAndroid) {
|
||||||
// android ONLY supports OIO (not NIO)
|
// android ONLY supports OIO (not NIO)
|
||||||
worker = new OioEventLoopGroup(0, new NamedThreadFactory(this.name + "-worker-UDP", nettyGroup));
|
worker = new OioEventLoopGroup(0, new NamedThreadFactory(this.name + "-worker-UDP", nettyGroup));
|
||||||
this.udpBootstrap.channel(OioDatagramChannel.class);
|
this.udpBootstrap.channel(OioDatagramChannel.class);
|
||||||
|
@ -5,7 +5,6 @@ import io.netty.channel.ChannelFuture;
|
|||||||
import io.netty.channel.EventLoopGroup;
|
import io.netty.channel.EventLoopGroup;
|
||||||
import io.netty.util.concurrent.EventExecutor;
|
import io.netty.util.concurrent.EventExecutor;
|
||||||
import io.netty.util.concurrent.Future;
|
import io.netty.util.concurrent.Future;
|
||||||
import io.netty.util.internal.PlatformDependent;
|
|
||||||
|
|
||||||
import java.security.AccessControlException;
|
import java.security.AccessControlException;
|
||||||
import java.security.SecureRandom;
|
import java.security.SecureRandom;
|
||||||
@ -85,11 +84,7 @@ public abstract class EndPoint {
|
|||||||
public static int udpMaxSize = 512;
|
public static int udpMaxSize = 512;
|
||||||
|
|
||||||
|
|
||||||
public static final boolean isAndroid;
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
isAndroid = PlatformDependent.isAndroid();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// doesn't work in eclipse.
|
// doesn't work in eclipse.
|
||||||
// Needed for NIO selectors on Android 2.2, and to force IPv4.
|
// Needed for NIO selectors on Android 2.2, and to force IPv4.
|
||||||
|
Loading…
Reference in New Issue
Block a user