public ObjectStore(Server server) { this.server = server; server.addMessageListener(serverEventHandler, RemoteObjectDefMessage.class, RemoteMethodCallMessage.class, RemoteMethodReturnMessage.class); server.addConnectionListener(serverEventHandler); }
/** * Creates a HostedServiceManager for the specified network Server. */ public HostedServiceManager( Server server ) { this.server = server; this.connectionObserver = new ConnectionObserver(); server.addConnectionListener(connectionObserver); }
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 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 ObjectStore(Server server) { this.server = server; server.addMessageListener(serverEventHandler, RemoteObjectDefMessage.class, RemoteMethodCallMessage.class, RemoteMethodReturnMessage.class); server.addConnectionListener(serverEventHandler); }
/** * Creates a HostedServiceManager for the specified network Server. */ public HostedServiceManager( Server server ) { this.server = server; this.connectionObserver = new ConnectionObserver(); server.addConnectionListener(connectionObserver); }
public ObjectStore(Server server) { this.server = server; server.addMessageListener(serverEventHandler, RemoteObjectDefMessage.class, RemoteMethodCallMessage.class, RemoteMethodReturnMessage.class); server.addConnectionListener(serverEventHandler); }
/** * Creates a new EntityDataHostService that will watch for new * connections on the specified Server and provide access to the * specified EntityData. Entity request and response messages will * be sent on the specified channel. */ public EntityDataHostService( Server server, int channel, ObservableEntityData ed ) { this.server = server; this.channel = channel; this.ed = ed; this.connectionObserver = new ConnectionObserver(); server.addConnectionListener(connectionObserver); // A general listener for forwarding the ES messages // to the client-specific handler SessionDataDelegator delegator = new SessionDataDelegator(HostedEntityData.class, HostedEntityData.ATTRIBUTE_NAME, true); server.addMessageListener(delegator, delegator.getMessageTypes()); }
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(); }