Added some logging for when the kernels are actually
hosting. The old SM did similar and it's useful. git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7019 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
f9976ec817
commit
90c01777ae
@ -42,6 +42,8 @@ import java.net.Socket;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.jme3.network.kernel.*;
|
||||
|
||||
@ -54,6 +56,8 @@ import com.jme3.network.kernel.*;
|
||||
*/
|
||||
public class SelectorKernel extends AbstractKernel
|
||||
{
|
||||
static Logger log = Logger.getLogger(SelectorKernel.class.getName());
|
||||
|
||||
private InetSocketAddress address;
|
||||
private SelectorThread thread;
|
||||
|
||||
@ -69,9 +73,9 @@ public class SelectorKernel extends AbstractKernel
|
||||
this( new InetSocketAddress(port) );
|
||||
}
|
||||
|
||||
public SelectorKernel( InetSocketAddress address )
|
||||
public SelectorKernel( InetSocketAddress address )
|
||||
{
|
||||
this.address = address;
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
protected SelectorThread createSelectorThread()
|
||||
@ -227,6 +231,8 @@ public class SelectorKernel extends AbstractKernel
|
||||
// Register the server socket channel, indicating an interest in
|
||||
// accepting new connections
|
||||
serverChannel.register(selector, SelectionKey.OP_ACCEPT);
|
||||
|
||||
log.log( Level.INFO, "Hosting TCP connection:{0}.", address );
|
||||
}
|
||||
|
||||
public void close() throws IOException, InterruptedException
|
||||
@ -273,9 +279,9 @@ public class SelectorKernel extends AbstractKernel
|
||||
// Setup the connection to be non-blocking
|
||||
SocketChannel remoteChan = serverChan.accept();
|
||||
remoteChan.configureBlocking(false);
|
||||
|
||||
|
||||
// And disable Nagle's buffering algorithm... we want
|
||||
// data to go when we put it there.
|
||||
// data to go when we put it there.
|
||||
Socket sock = remoteChan.socket();
|
||||
sock.setTcpNoDelay(true);
|
||||
|
||||
@ -381,6 +387,8 @@ public class SelectorKernel extends AbstractKernel
|
||||
|
||||
public void run()
|
||||
{
|
||||
log.log( Level.INFO, "Kernel started for connection:{0}.", address );
|
||||
|
||||
// An atomic is safest and costs almost nothing
|
||||
while( go.get() ) {
|
||||
// Setup any queued option changes
|
||||
|
@ -38,6 +38,8 @@ import java.nio.ByteBuffer;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.jme3.network.kernel.*;
|
||||
|
||||
@ -49,10 +51,12 @@ import com.jme3.network.kernel.*;
|
||||
*/
|
||||
public class UdpKernel extends AbstractKernel
|
||||
{
|
||||
static Logger log = Logger.getLogger(UdpKernel.class.getName());
|
||||
|
||||
private InetSocketAddress address;
|
||||
private HostThread thread;
|
||||
|
||||
// The nature of UDP means that even through a firewall,
|
||||
// The nature of UDP means that even through a firewall,
|
||||
// a user would have to have a unique address+port since UDP
|
||||
// can't really be NAT'ed.
|
||||
private Map<SocketAddress,UdpEndpoint> socketEndpoints = new ConcurrentHashMap<SocketAddress,UdpEndpoint>();
|
||||
@ -185,6 +189,7 @@ public class UdpKernel extends AbstractKernel
|
||||
public void connect() throws IOException
|
||||
{
|
||||
socket = new DatagramSocket( address );
|
||||
log.log( Level.INFO, "Hosting UDP connection:{0}.", address );
|
||||
}
|
||||
|
||||
public void close() throws IOException, InterruptedException
|
||||
@ -201,6 +206,8 @@ public class UdpKernel extends AbstractKernel
|
||||
|
||||
public void run()
|
||||
{
|
||||
log.log( Level.INFO, "Kernel started for connection:{0}.", address );
|
||||
|
||||
// An atomic is safest and costs almost nothing
|
||||
while( go.get() ) {
|
||||
try {
|
||||
|
Loading…
x
Reference in New Issue
Block a user