Modified KernelAdapter to be a more self-sufficient adapter

to better support having multiple channels.


git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8933 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
PSp..om 13 years ago
parent 48db901b5b
commit 5cb7e21157
  1. 16
      engine/src/networking/com/jme3/network/base/DefaultServer.java
  2. 17
      engine/src/networking/com/jme3/network/base/KernelAdapter.java
  3. 2
      engine/src/networking/com/jme3/network/message/ClientRegistrationMessage.java

@ -60,9 +60,7 @@ public class DefaultServer implements Server
private AtomicInteger nextId = new AtomicInteger(0);
private String gameName;
private int version;
private Kernel reliable;
private KernelAdapter reliableAdapter;
private Kernel fast;
private KernelAdapter fastAdapter;
private Redispatch dispatcher = new Redispatch();
private Map<Integer,HostedConnection> connections = new ConcurrentHashMap<Integer,HostedConnection>();
@ -84,8 +82,6 @@ public class DefaultServer implements Server
this.gameName = gameName;
this.version = version;
this.reliable = reliable;
this.fast = fast;
reliableAdapter = new KernelAdapter( this, reliable, dispatcher, true );
if( fast != null ) {
@ -109,9 +105,9 @@ public class DefaultServer implements Server
throw new IllegalStateException( "Server is already started." );
// Initialize the kernels
reliable.initialize();
if( fast != null ) {
fast.initialize();
reliableAdapter.initialize();
if( fastAdapter != null ) {
fastAdapter.initialize();
}
// Start em up
@ -161,12 +157,12 @@ public class DefaultServer implements Server
FilterAdapter adapter = filter == null ? null : new FilterAdapter(filter);
// Ignore the filter for the moment
if( message.isReliable() || fast == null ) {
if( message.isReliable() || fastAdapter == null ) {
// Don't need to copy the data because message protocol is already
// giving us a fresh buffer
reliable.broadcast( adapter, buffer, true, false );
reliableAdapter.broadcast( adapter, buffer, true, false );
} else {
fast.broadcast( adapter, buffer, false, false );
fastAdapter.broadcast( adapter, buffer, false, false );
}
}

@ -32,6 +32,7 @@
package com.jme3.network.base;
import com.jme3.network.Filter;
import com.jme3.network.HostedConnection;
import com.jme3.network.Message;
import com.jme3.network.MessageListener;
@ -89,6 +90,22 @@ public class KernelAdapter extends Thread
this.reliable = reliable;
setDaemon(true);
}
public Kernel getKernel()
{
return kernel;
}
public void initialize()
{
kernel.initialize();
}
public void broadcast( Filter<? super Endpoint> filter, ByteBuffer data, boolean reliable,
boolean copy )
{
kernel.broadcast( filter, data, reliable, copy );
}
public void close() throws InterruptedException
{

@ -36,7 +36,7 @@ import com.jme3.network.AbstractMessage;
import com.jme3.network.serializing.Serializable;
/**
* Client registration is a message that contains a unique ID. This ID
* Client registration is a message that contains a unique ID. This ID
* is simply the current time in milliseconds, providing multiple clients
* will not connect to the same server within one millisecond. This is used
* to couple the TCP and UDP connections together into one 'Client' on the

Loading…
Cancel
Save