Received messages now have their reliability flag

set properly based on how the message was received.


git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7068 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
PSp..om 14 years ago
parent 16c6b13564
commit ec7431e0f1
  1. 10
      engine/src/networking/com/jme3/network/Message.java
  2. 10
      engine/src/networking/com/jme3/network/base/ConnectorAdapter.java
  3. 4
      engine/src/networking/com/jme3/network/base/DefaultClient.java
  4. 4
      engine/src/networking/com/jme3/network/base/DefaultServer.java
  5. 9
      engine/src/networking/com/jme3/network/base/KernelAdapter.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();
}

@ -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 );
}
}

@ -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);
}
}

@ -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 );
}
}

@ -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 );
}
}

Loading…
Cancel
Save