Package com.esotericsoftware.kryonet

Examples of com.esotericsoftware.kryonet.Client.addListener()


    // ----

    Client client = new Client();
    register(client.getKryo());
    startEndPoint(client);
    client.addListener(new Listener() {
      public void received (Connection connection, Object object) {
        if (object instanceof SomeData) {
          SomeData data = (SomeData)object;
          System.out.println(data.stuff[3]);
        } else if (object instanceof SomeOtherData) {
View Full Code Here


    // ----

    final Client client = new Client();
    register(client.getKryo());
    startEndPoint(client);
    client.addListener(new Listener() {
      public void received (Connection connection, Object object) {
        if (object instanceof SomeData) {
          SomeData data = (SomeData)object;
          System.out.println(data.stuff[3]);
        } else if (object instanceof ArrayList) {
View Full Code Here

    ObjectSpace clientObjectSpace = new ObjectSpace(client);
    final TestObjectImpl clientTestObject = new TestObjectImpl(1234);
    clientObjectSpace.register((short)12, clientTestObject);

    startEndPoint(client);
    client.addListener(new Listener() {
      public void connected (final Connection connection) {
        RmiTest.runTest(connection, 42, 4321);
      }

      public void received (Connection connection, Object object) {
View Full Code Here

    ObjectSpace clientObjectSpace = new ObjectSpace(client);
    final TestObjectImpl clientTestObject = new TestObjectImpl(1234);
    clientObjectSpace.register((short)12, clientTestObject);

    startEndPoint(client);
    client.addListener(new Listener() {
      public void connected (final Connection connection) {
        RmiTest.runTest(connection, 42, 4321);
      }

      public void received (Connection connection, Object object) {
View Full Code Here

    // ----

    final Client client = new Client();
    register(client.getKryo());
    startEndPoint(client);
    client.addListener(new Listener() {
      public void received (Connection connection, Object object) {
        if (object instanceof SomeData) {
          SomeData data = (SomeData)object;
          System.out.println(data.stuff[3]);
        } else if (object instanceof ArrayList) {
View Full Code Here

    ObjectSpace clientObjectSpace = new ObjectSpace(client);
    final TestObjectImpl clientTestObject = new TestObjectImpl(1234);
    clientObjectSpace.register(12, clientTestObject);

    startEndPoint(client);
    client.addListener(new Listener() {
      public void connected (final Connection connection) {
        runTest(connection, 42, 4321);
      }

      public void received (Connection connection, Object object) {
View Full Code Here

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

    startEndPoint(client);
    client.addListener(new Listener() {
      public void connected (final Connection connection) {
        new Thread() {
          public void run () {
            TestObject test = ObjectSpace.getRemoteObject(connection, 42, TestObject.class);
            test.other();
View Full Code Here

    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

TOP
Copyright © 2018 www.massapi.com. 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.