Package com.esotericsoftware.kryonet

Examples of com.esotericsoftware.kryonet.Listener


    // Both objects must be registered with the ObjectSpace.
    final ObjectSpace serverObjectSpace = new ObjectSpace();
    serverObjectSpace.register(42, serverTestObject);
    serverObjectSpace.register(777, serverTestObject.getOtherObject());

    server.addListener(new Listener() {
      public void connected (final Connection connection) {
        // Allow the connection to access objects in the ObjectSpace.
        serverObjectSpace.addConnection(connection);
      }

      public void received (Connection connection, Object object) {
        // The test is complete when the client sends the OtherObject instance.
        if (object == serverTestObject.getOtherObject()) stopEndPoints();
      }
    });

    // ----

    Client client = new Client();
    register(client.getKryo());
    startEndPoint(client);

    // The ThreadedListener means the network thread won't be blocked when waiting for RMI responses.
    client.addListener(new ThreadedListener(new Listener() {
      public void connected (final Connection connection) {
        TestObject test = ObjectSpace.getRemoteObject(connection, 42, TestObject.class);
        // Normal remote method call.
        assertEquals(43.21f, test.other());
        // Make a remote method call that returns another remote proxy object.
View Full Code Here


        final Client client = new Client();
        client.start();
        client.connect(5_000, "localhost", 12_345);

        client.addListener(new Listener() {
            @Override
            public void received(Connection connection, Object object) {
                LOG.log(Level.INFO, "Received message {0} in thread {1}", new Object[]{object.toString(), Thread.currentThread().toString()});
                try {
                    Thread.sleep(100);
View Full Code Here

        kryo.register(Packet.class);       
       
        client.start();
        client.connect(5_000, "localhost", 12_345);       
       
        client.addListener(new Listener() {
            @Override
            public void received(Connection connection, Object object) {
                System.out.println("type of object " + object.getClass().getName());
                if (object instanceof Packet) {
                    System.out.println("type of content " + ((Packet) object).getContent().getClass().getName());
View Full Code Here

    kryo.register(NetBiome.class);
    kryo.register(NetBiome[].class);
    kryo.register(NetInfoRequest.class);
    kryo.register(int[].class);
   
    client.addListener(new Listener() {
      @Override
      public void received(Connection connection, Object object) {
        if (object instanceof NetGetBiomeDataResult) {
          currentResults = (NetGetBiomeDataResult)object;
          //Log.i("Received NetGetBiomeDataResult: " + currentResults);
View Full Code Here

    public RemoteInvocationHandler (Connection connection, final int objectID) {
      super();
      this.connection = connection;
      this.objectID = objectID;

      responseListener = new Listener() {
        public void received (Connection connection, Object object) {
          if (!(object instanceof InvokeMethodResult)) return;
          InvokeMethodResult invokeMethodResult = (InvokeMethodResult)object;
          if (invokeMethodResult.objectID != objectID) return;
View Full Code Here

TOP

Related Classes of com.esotericsoftware.kryonet.Listener

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.