/** * 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 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 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 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(); } } }
client = Network.connectToServer(TestChatServer.NAME, TestChatServer.VERSION, host, TestChatServer.PORT, TestChatServer.UDP_PORT); client.addMessageListener(new ChatHandler(), ChatMessage.class);
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); } }
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); }
server.start(); client = Network.connectToServer("localhost", 5110); client.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 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 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 ); }
/** * 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 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 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 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 ); }
@Override public void run() { NetworkServer server; while (true) { synchronized(queue) { if (queue.isEmpty() || isInterrupted()) { break; } server = queue.pop(); } try { //InetAddress ipAddress = InetAddress.getByName(server.getHost()); //if (!ipAddress.isReachable(null, 255, 500)) { continue; } Client client = Network.connectToServer(server.getHost(), server.getPort()); client.start(); server.setName(client.getGameName()); onFound(server); client.close(); } catch (IOException ex) { logger.log(java.util.logging.Level.SEVERE, String.format("No %s. %s", server.getHost(), ex.getLocalizedMessage())); } } }
public NetworkClient(String host, int port) throws IOException { client = Network.connectToServer(NetworkConstants.GAME_NAME, NetworkConstants.PROTOCOL_VERSION, host, port); client.addClientStateListener(new ClientStateChangeListener(this)); //this.ed = new RemoteEntityData(client, 0); //ObjectMessageDelegator delegator = new ObjectMessageDelegator(this, true); // client.addMessageListener(delegator, delegator.getMessageTypes()); client.getServices().addServices(new RpcClientService(), new RmiClientService(), new AccountClientService(), new LobbyClientService(), new ChatClientService(), new EtherealClient(NetworkConstants.OBJECT_PROTOCOL, NetworkConstants.ZONE_GRID, NetworkConstants.ZONE_RADIUS)); }