diff --git a/engine/src/networking/com/jme3/network/Message.java b/engine/src/networking/com/jme3/network/Message.java index 9f8e4d080..52adfe9a7 100644 --- a/engine/src/networking/com/jme3/network/Message.java +++ b/engine/src/networking/com/jme3/network/Message.java @@ -43,5 +43,15 @@ import com.jme3.network.serializing.Serializable; @Serializable() public interface Message { + /** + * Sets this message to 'reliable' or not and returns this + * message. + */ + public Message setReliable(boolean f); + + /** + * Indicates which way an outgoing message should be sent + * or which way an incoming message was sent. + */ public boolean isReliable(); } diff --git a/engine/src/networking/com/jme3/network/base/ConnectorAdapter.java b/engine/src/networking/com/jme3/network/base/ConnectorAdapter.java index f66335c76..abab43472 100644 --- a/engine/src/networking/com/jme3/network/base/ConnectorAdapter.java +++ b/engine/src/networking/com/jme3/network/base/ConnectorAdapter.java @@ -64,11 +64,16 @@ public class ConnectorAdapter extends Thread private MessageListener dispatcher; private AtomicBoolean go = new AtomicBoolean(true); - public ConnectorAdapter( Connector connector, MessageListener dispatcher ) + // Marks the messages as reliable or not if they came + // through this connector. + private boolean reliable; + + public ConnectorAdapter( Connector connector, MessageListener dispatcher, boolean reliable ) { super( String.valueOf(connector) ); - this.connector = connector; + this.connector = connector; this.dispatcher = dispatcher; + this.reliable = reliable; setDaemon(true); } @@ -105,6 +110,7 @@ public class ConnectorAdapter extends Thread Message m = null; while( (m = protocol.getMessage()) != null ) { + m.setReliable( reliable ); dispatch( m ); } } diff --git a/engine/src/networking/com/jme3/network/base/DefaultClient.java b/engine/src/networking/com/jme3/network/base/DefaultClient.java index e15c9f67f..c7f71cd09 100644 --- a/engine/src/networking/com/jme3/network/base/DefaultClient.java +++ b/engine/src/networking/com/jme3/network/base/DefaultClient.java @@ -92,10 +92,10 @@ public class DefaultClient implements Client this.reliable = reliable; this.fast = fast; if( reliable != null ) { - reliableAdapter = new ConnectorAdapter(reliable, dispatcher); + reliableAdapter = new ConnectorAdapter(reliable, dispatcher, true); } if( fast != null ) { - fastAdapter = new ConnectorAdapter(fast, dispatcher); + fastAdapter = new ConnectorAdapter(fast, dispatcher, false); } } diff --git a/engine/src/networking/com/jme3/network/base/DefaultServer.java b/engine/src/networking/com/jme3/network/base/DefaultServer.java index 27765a338..cdc156d34 100644 --- a/engine/src/networking/com/jme3/network/base/DefaultServer.java +++ b/engine/src/networking/com/jme3/network/base/DefaultServer.java @@ -88,9 +88,9 @@ public class DefaultServer implements Server this.reliable = reliable; this.fast = fast; - reliableAdapter = new KernelAdapter( this, reliable, dispatcher ); + reliableAdapter = new KernelAdapter( this, reliable, dispatcher, true ); if( fast != null ) { - fastAdapter = new KernelAdapter( this, fast, dispatcher ); + fastAdapter = new KernelAdapter( this, fast, dispatcher, false ); } } diff --git a/engine/src/networking/com/jme3/network/base/KernelAdapter.java b/engine/src/networking/com/jme3/network/base/KernelAdapter.java index 155e43be8..8c5d5576c 100644 --- a/engine/src/networking/com/jme3/network/base/KernelAdapter.java +++ b/engine/src/networking/com/jme3/network/base/KernelAdapter.java @@ -66,12 +66,18 @@ public class KernelAdapter extends Thread private MessageListener messageDispatcher; private AtomicBoolean go = new AtomicBoolean(true); - public KernelAdapter( DefaultServer server, Kernel kernel, MessageListener messageDispatcher ) + // Marks the messages as reliable or not if they came + // through this connector. + private boolean reliable; + + public KernelAdapter( DefaultServer server, Kernel kernel, MessageListener messageDispatcher, + boolean reliable ) { super( String.valueOf(kernel) ); this.server = server; this.kernel = kernel; this.messageDispatcher = messageDispatcher; + this.reliable = reliable; setDaemon(true); } @@ -139,6 +145,7 @@ public class KernelAdapter extends Thread // Should be complete... and maybe we should check but we don't Message m = null; while( (m = protocol.getMessage()) != null ) { + m.setReliable(reliable); dispatch( env.getSource(), m ); } }