public static void main(String[] args) throws IOException, InterruptedException{ Logger.getLogger("").getHandlers()[0].setLevel(Level.OFF); Server server = Network.createServer(5110); server.start(); server.addConnectionListener(new TestNetworkStress()); for (int i = 0; i < 1000; i++){ Client client = Network.connectToServer("localhost", 5110); client.start(); Thread.sleep(10); client.close(); } } }
/** * Creates a client that can be connected at a later time. */ public static NetworkClient createClient() { return createClient( DEFAULT_GAME_NAME, DEFAULT_VERSION ); }
/** * Creates a Client that communicates with the specified host and port * using both reliable and fast transports. */ public static Client connectToServer( String host, int hostPort ) throws IOException { return connectToServer( DEFAULT_GAME_NAME, DEFAULT_VERSION, host, hostPort, hostPort ); }
/** * Creates a Server that will utilize both reliable and fast * transports to communicate with clients. The specified port * will be used for both TCP and UDP communication. */ public static Server createServer( int tcpPort, int udpPort ) throws IOException { return createServer( DEFAULT_GAME_NAME, DEFAULT_VERSION, tcpPort, udpPort ); }
/** * Creates a Client that communicates with the specified host and separate TCP and UDP ports * using both reliable and fast transports. */ public static Client connectToServer( String host, int hostPort, int remoteUdpPort ) throws IOException { return connectToServer( DEFAULT_GAME_NAME, DEFAULT_VERSION, host, hostPort, remoteUdpPort ); }
/** * Creates a Server that will utilize both reliable and fast * transports to communicate with clients. The specified port * will be used for both TCP and UDP communication. */ public static Server createServer( int port ) throws IOException { return createServer( DEFAULT_GAME_NAME, DEFAULT_VERSION, port, port ); }
public static void main(String[] args) throws IOException, InterruptedException{ Serializer.registerClass(SomeObject.class); Serializer.registerClass(TestSerializationMessage.class); Server server = Network.createServer( 5110 ); server.start(); Client client = Network.connectToServer( "localhost", 5110 ); client.start(); server.addMessageListener(new TestSerialization(), TestSerializationMessage.class); client.send(new TestSerializationMessage(true)); Thread.sleep(10000); }
/** * Creates a Client that communicates with the specified host and port * using both reliable and fast transports. */ public static Client connectToServer( String gameName, int version, String host, int hostPort ) throws IOException { return connectToServer( gameName, version, host, hostPort, hostPort ); }
public static void createServer(){ serverApp = new SimpleApplication() { @Override public void simpleInitApp() { } }; serverApp.start(); try { Server server = Network.createServer(5110); server.start(); ObjectStore store = new ObjectStore(server); store.exposeObject("access", new ServerAccessImpl()); } catch (IOException ex) { ex.printStackTrace(); } }
/** * Creates a client that can be connected at a later time. */ public static NetworkClient createClient() { return createClient( DEFAULT_GAME_NAME, DEFAULT_VERSION ); }
public static void main(String[] args) throws IOException, InterruptedException{ Serializer.registerClass(PingMessage.class); Serializer.registerClass(PongMessage.class); Server server = Network.createServer(5110); server.start(); Client client = Network.connectToServer("localhost", 5110); client.start(); server.addMessageListener(new ServerPingResponder(), PingMessage.class); client.addMessageListener(new ClientPingResponder(), PongMessage.class); System.out.println("Client: Sending ping message.."); client.send(new PingMessage()); Object obj = new Object(); synchronized (obj){ obj.wait(); } } }
client = Network.connectToServer(TestChatServer.NAME, TestChatServer.VERSION, host, TestChatServer.PORT, TestChatServer.UDP_PORT); client.addMessageListener(new ChatHandler(), ChatMessage.class);
public TestChatServer() throws IOException { // Use this to test the client/server name version check this.server = Network.createServer(NAME, VERSION, PORT, UDP_PORT); // Initialize our own messages only after the server has been created. // It registers some additional messages with the serializer by default // that need to go before custom messages. initializeClasses(); ChatHandler handler = new ChatHandler(); server.addMessageListener(handler, ChatMessage.class); server.addConnectionListener(new ChatConnectionListener()); }
/** * Creates a client that can be connected at a later time. */ public static NetworkClient createClient() { return createClient( DEFAULT_GAME_NAME, DEFAULT_VERSION ); }
public static void main(String[] args) throws IOException, InterruptedException { Serializer.registerClass(TestMessage.class); // Use this to test the client/server name version check //Server server = Network.createServer( "bad name", 42, 5110, 5110 ); Server server = Network.createServer(5110, 5110); server.start(); Client client = Network.connectToServer("localhost", 5110); client.start(); client.addMessageListener(new TestThroughput(false), TestMessage.class); server.addMessageListener(new TestThroughput(true), TestMessage.class); Thread.sleep(1); TestMessage test = new TestMessage(); // for( int i = 0; i < 10; i++ ) { while (true) { //System.out.println( "sending." ); client.send(test); } //Thread.sleep(5000); } }
public static void main(String[] args) throws IOException, InterruptedException{ Serializer.registerClass(Savable.class, new SavableSerializer()); createServer(); Client client = Network.connectToServer("localhost", 5110); client.start(); ObjectStore store = new ObjectStore(client); ServerAccess access = store.getExposedObject("access", ServerAccess.class, true); boolean result = access.attachChild("Models/Oto/Oto.mesh.xml"); System.out.println(result); } }
/** * Creates a Server that will utilize both reliable and fast * transports to communicate with clients. The specified port * will be used for both TCP and UDP communication. */ public static Server createServer( int tcpPort, int udpPort ) throws IOException { return createServer( DEFAULT_GAME_NAME, DEFAULT_VERSION, tcpPort, udpPort ); }
public static void main(String[] args) throws IOException, InterruptedException{ Serializer.registerClass(TimestampMessage.class); Server server = Network.createServer(5110); server.start(); client = Network.connectToServer("localhost", 5110); client.start();
/** * Creates a Client that communicates with the specified host and separate TCP and UDP ports * using both reliable and fast transports. */ public static Client connectToServer( String host, int hostPort, int remoteUdpPort ) throws IOException { return connectToServer( DEFAULT_GAME_NAME, DEFAULT_VERSION, host, hostPort, remoteUdpPort ); }
/** * Creates a Server that will utilize both reliable and fast * transports to communicate with clients. The specified port * will be used for both TCP and UDP communication. */ public static Server createServer( int port ) throws IOException { return createServer( DEFAULT_GAME_NAME, DEFAULT_VERSION, port, port ); }