From b73f71aeff5549859c27f2698b21ae4f40440877 Mon Sep 17 00:00:00 2001 From: "PSp..om" Date: Sat, 19 Mar 2011 06:31:37 +0000 Subject: [PATCH] Updated to use localhost instead of my hard-coded host and modified to be able to test unreliable throughput. git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7036 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../test/jme3test/network/TestThroughput.java | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/engine/src/test/jme3test/network/TestThroughput.java b/engine/src/test/jme3test/network/TestThroughput.java index cfcd83124..d35ea7f74 100644 --- a/engine/src/test/jme3test/network/TestThroughput.java +++ b/engine/src/test/jme3test/network/TestThroughput.java @@ -32,16 +32,12 @@ package jme3test.network; -//import com.jme3.network.connection.OldClient; -//import com.jme3.network.connection.OldServer; import com.jme3.network.Client; import com.jme3.network.Message; import com.jme3.network.MessageConnection; import com.jme3.network.MessageListener; import com.jme3.network.Network; import com.jme3.network.Server; -//import com.jme3.network.events.MessageAdapter; -//import com.jme3.network.message.Message; import com.jme3.network.serializing.Serializable; import com.jme3.network.serializing.Serializer; import java.io.IOException; @@ -51,9 +47,11 @@ public class TestThroughput implements MessageListener { //ex private static long lastTime = -1; private static long counter = 0; private static long total = 0; -// private static OldClient client; private static Client client; + // Change this flag to test UDP instead of TCP + private static boolean testReliable = true; + private boolean isOnServer; public TestThroughput( boolean isOnServer ) { @@ -81,9 +79,12 @@ public class TestThroughput implements MessageListener { //ex } } else { if( source == null ) { -System.out.println( "Received a message from a not fully connected source, msg:"+ msg ); + System.out.println( "Received a message from a not fully connected source, msg:"+ msg ); } else { //System.out.println( "sending:" + msg + " back to client:" + source ); + // The 'reliable' flag is transient and the server doesn't + // (yet) reset this value for us. + ((com.jme3.network.message.Message)msg).setReliable(testReliable); source.send(msg); } } @@ -93,14 +94,10 @@ System.out.println( "Received a message from a not fully connected source, msg:" Serializer.registerClass(TestMessage.class); - //OldServer server = new OldServer(5110, 5110); - //server.start(); Server server = Network.createServer( 5110 ); server.start(); - //client = new OldClient("localhost", 5110, 5110); - //client.start(); - Client client = Network.connectToServer( "hydra", 5110, 5000 ); + Client client = Network.connectToServer( "localhost", 5110, 5000 ); client.start(); client.addMessageListener(new TestThroughput(false), TestMessage.class); @@ -122,7 +119,7 @@ System.out.println( "Received a message from a not fully connected source, msg:" public static class TestMessage extends com.jme3.network.message.Message { public TestMessage(){ - setReliable(true); + setReliable(testReliable); } }