Package com.esotericsoftware.kryonet

Examples of com.esotericsoftware.kryonet.Listener$QueuedListener


    // For consistency, the classes to be sent over the network are
    // registered by the same method for both the client and server.
    Network.register(client);

    client.addListener(new Listener() {
      public void connected (Connection connection) {
        RegisterName registerName = new RegisterName();
        registerName.name = name;
        client.sendTCP(registerName);
      }
View Full Code Here


    final ObjectSpace serverObjectSpace = new ObjectSpace();
    final TestObjectImpl serverTestObject = new TestObjectImpl(4321);
    serverObjectSpace.register((short)42, serverTestObject);

    server.addListener(new Listener() {
      public void connected (final Connection connection) {
        serverObjectSpace.addConnection(connection);
        runTest(connection, 12, 1234);
      }

      public void received (Connection connection, Object object) {
        if (!(object instanceof MessageWithTestObject)) return;
        MessageWithTestObject m = (MessageWithTestObject)object;
        System.out.println(serverTestObject.value);
        System.out.println(((TestObjectImpl)m.testObject).value);
        assertEquals(4321f, m.testObject.other());
        stopEndPoints(2000);
      }
    });

    // ----

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

    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

    // For consistency, the classes to be sent over the network are
    // registered by the same method for both the client and server.
    Network.register(server);

    server.addListener(new Listener() {
      public void received (Connection c, Object object) {
        // We know all connections for this server are actually ChatConnections.
        ChatConnection connection = (ChatConnection)c;

        if (object instanceof RegisterName) {
View Full Code Here

    a.add(null);
    a.add(34);

    startEndPoint(server);
    server.bind(tcpPort, udpPort);
    server.addListener(new Listener() {
      public void connected (Connection connection) {
        server.sendToAllTCP(data);
        connection.sendTCP(data);
        connection.sendTCP(a);
      }
    });

    // ----

    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

    // For consistency, the classes to be sent over the network are
    // registered by the same method for both the client and server.
    Network.register(server);

    server.addListener(new Listener() {
      public void received (Connection c, Object object) {
        // We know all connections for this server are actually CharacterConnections.
        CharacterConnection connection = (CharacterConnection)c;
        Character character = connection.character;
View Full Code Here

    // For consistency, the classes to be sent over the network are
    // registered by the same method for both the client and server.
    Network.register(client);

    // ThreadedListener runs the listener methods on a different thread.
    client.addListener(new ThreadedListener(new Listener() {
      public void connected (Connection connection) {
      }

      public void received (Connection connection, Object object) {
        if (object instanceof RegistrationRequired) {
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

    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

    final TestObjectImpl serverTestObject = new TestObjectImpl(4321);

    final ObjectSpace serverObjectSpace = new ObjectSpace();
    serverObjectSpace.register(42, serverTestObject);

    server.addListener(new Listener() {
      public void connected (final Connection connection) {
        serverObjectSpace.addConnection(connection);
        runTest(connection, 12, 1234);
      }

      public void received (Connection connection, Object object) {
        if (!(object instanceof MessageWithTestObject)) return;
        MessageWithTestObject m = (MessageWithTestObject)object;
        System.out.println(serverTestObject.value);
        System.out.println(((TestObjectImpl)m.testObject).value);
        assertEquals(4321f, m.testObject.other());
        stopEndPoints(2000);
      }
    });

    // ----

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

    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

    final TestObjectImpl serverTestObject = new TestObjectImpl(4321);

    final ObjectSpace serverObjectSpace = new ObjectSpace();
    serverObjectSpace.register(42, serverTestObject);

    server.addListener(new Listener() {
      public void connected (final Connection connection) {
        serverObjectSpace.addConnection(connection);
      }

      public void received (Connection connection, Object object) {
        if (object instanceof MessageWithTestObject) {
          assertEquals(256 + 512 + 1024, serverTestObject.moos);
          stopEndPoints(2000);
        }
      }
    });

    // ----

    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

TOP

Related Classes of com.esotericsoftware.kryonet.Listener$QueuedListener

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.