/** * 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 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{ 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(); } } }
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(); } }
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()); }
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(); } } }
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); }
public static void main(String[] args) throws IOException, InterruptedException{ Serializer.registerClass(TimestampMessage.class); Server server = Network.createServer(5110); server.start();
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); } }
/** * 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 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 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 ); }
/** * 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 void start() throws IOException { if (server == null) { server = Network.createServer(NetworkConstants.GAME_NAME, NetworkConstants.PROTOCOL_VERSION, port, port); } server.addChannel(port + 1); // Lobby server.addChannel(port + 2); // Chat initialize(); server.addConnectionListener(new ServerConnectionListener(this)); // Adding a delay for the connectionAdded right after the serializer registration // service gets to run let's the client get a small break in the buffer that should // generally prevent the RpcCall messages from coming too quickly and getting processed // before the SerializerRegistrationMessage has had a chance to process. // This "feature" happens with Linux almost all the time server.getServices().addService(new DelayService()); server.getServices().addServices(new RpcHostedService(), new RmiHostedService(), new AccountHostedService(name), new LobbyHostedService(), new ChatHostedService() ); // Add the SimEtheral host that will serve object sync updates to // the clients. EtherealHost ethereal = new EtherealHost(NetworkConstants.OBJECT_PROTOCOL, NetworkConstants.ZONE_GRID, NetworkConstants.ZONE_RADIUS); server.getServices().addService(ethereal); server.start(); start = System.nanoTime(); }